#include #include using namespace std; int main() { uint32_t n, m; cin >> n >> m; uint32_t prev2 = 0, prev1 = 1; uint32_t fib; for (uint32_t i = 3; i <= n; i++) { fib = prev2 + prev1; if (fib > m) fib -= m; prev2 = prev1; prev1 = fib; } cout << fib << endl; }