#include #include using namespace std; auto fib_mod(size_t n, size_t m) { size_t memo[1000] = {0, 1}, i; for (i = 2; i <= n; i++) { memo[i] = (memo[i - 1] + memo[i - 2])%m; } return memo[n]; } int main(){ size_t n,m; cin >> n >> m; cout << fib_mod(n-1,m) << '\n'; }