#include using namespace std; long long fib(long long num) { long long dp[100]; //計算結果を入れる dp[0] = 0; dp[1] = 1; for (int i = 2; i <= num-1; i++) { dp[i] = dp[i - 1] + dp[i - 2]; } return dp[num-1]; } int main(void){ long long n, m; cin >> n >> m; cout << fib(n)%m << endl; return 0; }