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