N,M = map(int,input().split()) dp = [0,1] for i in range(N-2): dp[0],dp[1] = dp[1],dp[0]+dp[1] print(dp[(N+1)%2]%M)