#include #define ll long long #define MAX_N 5000010 using namespace std; ll dp[MAX_N]; int main(){ ll n,m; cin >> n >> m; dp[0] = 0; dp[1] = 1; if(n == 0 || n == 1){ cout << n << endl; return 0; } for(int i=2;i <= n;i++){ dp[i] = dp[i-1]%m + dp[i-2]%m; dp[i] %= m; } cout << dp[n] << endl; return 0; }