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