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