#include using namespace std; typedef pair pii; typedef pair pll; typedef vector vi; typedef vector vl; typedef vector vvi; typedef vector vvl; #define all(v) v.begin(), v.end() #define pr print /* REP macro */ #define repe(i, a, n) for (long i = (a); i <= (long)(n); ++i) #define rep(i, n) repe(i, 0, n-1) #define repd(i, n) for (int i = (long)(n-1); i >= 0; i--) /* func */ template bool chmin(T &a, const T &b) {bool compare = a > b; if (compare) a = b; return compare;} template bool chmax(T &a, const T &b) {bool compare = a < b; if (compare) a = b; return compare;} template inline void print(const T &a) {cout << a << endl;} template void print(Head head, Tail... tail) { cout << head << ' '; print(tail...); } template ostream& operator << (ostream &ostr, const vector &v){ cout << '{'; for(auto it = v.begin(); it < v.end(); it++){ if (it == v.end()-1) cout << *it; else cout << *it << ", "; } cout << '}'; return ostr; } template ostream& operator << (ostream &ostr, const pair &p){ cout << '(' << p.first << ", " << p.second << ')'; return ostr; } template T min(const vector &v){ return accumulate(all(v), v.front(), [](T acc, T i){ return min(acc, i);} ); } template T umin(const vector &v){ T top = (v.front() < 0 ? -1 : v.front()); return accumulate(all(v), top, [](T acc, T i){ if (i < 0) return acc; return min(acc, i);} ); } int MOD = 1000000007; struct mint{ long val; mint(long val=0) : val((val % MOD + MOD) % MOD) {} mint operator-() { return mint(-val); } mint& operator+=(const mint& a) { if ((val += a.val) >= MOD) val -= MOD; return *this; } mint& operator-=(const mint& a) { if ((val += MOD-a.val) >= MOD) val -= MOD; return *this; } mint& operator*=(const mint& a) { (val *= a.val) %= MOD; return *this; } mint operator+(const mint &a){ mint b = *this; return b += a; } mint operator-(const mint &a){ mint b = *this; return b -= a; } mint operator*(const mint &a){ mint b = *this; return b *= a; } mint& operator++(){ return *this += mint(1); } mint& operator--(){ return *this -= mint(1); } mint operator++(int){ mint b = *this; *this += mint(1); return b; } mint operator--(int){ mint b = *this; *this -= mint(1); return b; } mint pow(long n) const { if (n == 0) return 1; mint t = pow(n>>1); t *= t; if (n % 2 == 1) t *= *this; return t; } mint inv() const { return pow(MOD-2); } mint& operator/=(const mint& a) { return (*this) *= a.inv(); } mint operator/(const mint& a){ mint b = *this; return b/=a; } mint operator==(const mint& a){ return this->val == a.val; } mint operator!=(const mint& a){ return this->val != a.val; } }; ostream& operator<<(ostream& os, const mint& m){ os << m.val; return os; } mint pow(const mint &a, long n){ return a.pow(n); } struct UnionFind { vl par; vl si; UnionFind(long N) : par(N), si(N) { rep(i, N) { par[i] = i; si[i] = 1; } } long root(long x) { if (par[x] == x) return x; return par[x] = root(par[x]); } void unite(long x, long y) { int rx = root(x); int ry = root(y); if (rx == ry) return; par[rx] = ry; si[ry] += si[rx]; } bool same(int x, int y) { int rx = root(x); int ry = root(y); return rx == ry; } long size(int x){ return si[root(x)]; } }; int main(){ long N, M; cin >> N >> M; MOD = M; vector dp(N+1); dp[0] = 0; dp[1] = 0; dp[2] = 1; repe(i, 3, N){ dp[i] = dp[i-1] + dp[i-2]; } pr(dp[N]); }