#include #include #include #include #include #include using namespace std; int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); int n, m; cin >> n >> m; unsigned long a = 0,b = 1,c = 1; for(int i = 1; i < n; i++){ c = (a + b) % m; b = a; a = c; } cout << c << endl; }