#include #define int long long using namespace std; const int MOD = 1000000007; using Graph = vector>; signed main() { int N, M; cin >> N >> M; int bef2 = 0; int bef = 1; int now = 0; for( int i = 2; i < N; i++ ){ now = bef2 + bef; now %= M; bef2 = bef; bef = now; //cout << now << endl; } cout << now << endl; }