#include #include #include #include #include #include #include using namespace std; long long dp[6000000], n, m; int main() { cin >> n >> m; dp[1] = 0; dp[2] = 1; for (int i = 3; i < 5500000; i++)dp[i] = (dp[i - 1] + dp[i - 2]) % m; cout << dp[n] << endl; return 0; }