#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { long long N, M; cin >> N >> M; long long A[350000]; A[1] = 0; A[2] = 1; for (int i = 3; i <= N; i++) { A[i] = (A[i - 1] + A[i - 2]) % M; } cout << A[N] << endl; }