#include #include #include #include #include using namespace std; int N; long long M; int memo[5000000]; int func(int n){ if(n<=1) return 1; if(memo[n] != 0) return memo[n]; return memo[n] = func(n-1) + func(n-2); } int main() { cin >> N >> M; memo[1] = 0; memo[2] = 1; memo[3] = 1; cout << func(N)%M << endl; return 0; }