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