#include #define rep(i,n) for(int i=0;i<(int)n;i++) using namespace std; using ll = long long; using P = pair; int main() { ll n, m; cin >> n >> m; vector ans(n, 0); ans[0] = 0, ans[1] = 1; for (int i = 2; i < n; i++) { ans[i] = ans[i - 1] + ans[i - 2]; ans[i] %= m; } cout << ans[n - 1] << endl; return 0; }