#include using namespace std; int main(void) { int n, m; cin >> n >> m; int a = 0, b = 1, c; for (int i = 3; i <= n; i++) { c = (a + b) % m; a = b, b = c; } cout << c << endl; return 0; }