#include int main(){ long long int n,m; std::cin >> n >> m; int dp[n]; dp[0] = 1; dp[1] = 1; for(int i = 2; i < n; i++) dp[i] = dp[i-1]+dp[i-2]; std::cout << dp[n-1] % m << std::endl; }