#include #define PI 3.14159265359 using namespace std; const int64_t MOD = 1e9 + 7; int main() { uint64_t N, M; cin >> N >> M; vector v = { 0,1 }; int cnt = 2; while (cnt < N) { uint64_t a, b, c; a = v.at(v.size() - 2); b = v.at(v.size() - 1); c = (a + b) % M; v.push_back(c); cnt++; } cout << v.at(v.size() - 1) << endl; }