def F(x): if x==1:return 0 elif x==2:return 1 else: return F(x-1)+F(x-2) n,m=map(int,input().split()) print(F(n)%m)