#include using namespace std; unsigned long long memo[5000000]; unsigned long long fibo(int n) { if(memo[n] != -1) { return memo[n]; } else if(n == 1) { return 0; } else if(n == 2) { return 1; } unsigned long long res = fibo(n-1) + fibo(n-2); memo[n] = res; return res; } int main() { int n, m; cin >> n >> m; for (int i=0; i<5000000; i++) { memo[i] = -1; } cout << fibo(n) % m << endl; return 0; }