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