#include #define rep(i,n) for(int i=0;i<(n);++i) #define all(a) (a).begin(),(a).end() #define dunk(a) cout << (a) << endl using namespace std; typedef long long ll; int main() { ios::sync_with_stdio(false); cin.tie(0); int n; ll m; cin >> n >> m; vector fibo(n + 1); fibo[1] = 0; fibo[2] = 1; for (int i = 3; i <= n; ++i) { fibo[i] = fibo[i - 1] % m + fibo[i - 2] % m; fibo[i] %= m; } dunk(fibo[n]); return 0; }