#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { int32_t n, m; cin >> n >> m; if (n == 1 || n == 2) { cout << n - 1 << endl; return 0; } int32_t x = 0, y = 1; for (auto i = 3; i <= n; ++i) { auto t = (x + y) % m; x = y; y = t; } cout << y << endl; return 0; }