//#pragma warning(disable:4996) //#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //#include #include #include #include #include //#include //< in.txt > out.txt using namespace std; //std::ios::sync_with_stdio(false); //std::cin.tie(0); const long long MOD = 1e9 + 7; const long long INF = 1e18; typedef long long LL; typedef long double LD; //typedef boost::multiprecision::cpp_int bigint; typedef pair PLL; typedef pair PI; typedef pair pdl; typedef pair pdd; typedef vector VLL; typedef vector VVLL; typedef vector VI; typedef vector> VVI; typedef unsigned long long ULL; template inline void chmin(T& a, T b) { a = min(a, b); } template inline void chmax(T& a, T b) { a = max(a, b); } void input(); void solve(); void daminput(); int main() { std::cin.tie(0); std::ios::sync_with_stdio(false); input(); //daminput(); solve(); return 0; } ////////////////////////////////////////////////// ////////////////////////////////////////////////// int N, M; void input() { cin >> N >> M; } void daminput() { } void solve() { VLL F(N, 0); F[1] = 1; for (int n = 2; n < N; n++) { F[n] = (F[n - 1] + F[n - 2]) % M; } cout << F.back() << "\n"; }