n,m=map(int,input().split()) def test(n,m): dp=[0]*n dp[1]=1 for i in range(2,n): dp[i]=(dp[i-2]+dp[i-1])%m return dp[-1] print(test(n,m))