#include "iostream" #include "climits" #include "list" #include "queue" #include "stack" #include "set" #include "functional" #include "algorithm" #include "math.h" #include "utility" #include "string" #include "map" #include "unordered_map" #include "iomanip" #include "random" using namespace std; const long long int MOD = 1000000007; list Prime(int M) { listP; P.push_back(2); P.push_back(3); for (int i = 5; i <= M; i += 6) { bool flag = true; for (auto j : P) { if (i%j == 0) { flag = false; break; } } if (flag)P.push_back(i); flag = true; for (auto j : P) { if ((i + 2) % j == 0) { flag = false; break; } } if (flag)P.push_back(i + 2); } return P; } long long int N, K, Q, M; long long int num[5000001]; int main() { ios::sync_with_stdio(false); cin >> N >> M; num[1] = 0; num[2] = 1; for (int i = 3; i <= N; i++) { num[i] = num[i - 1] + num[i - 2]; num[i] %= M; } cout << num[N] << endl; return 0; }