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]) return dp[-1]%m print(test(n,m))