N, M = [int(x) for x in input().split()] a = 0 b = 1 for x in range(N-1): a, b = b, a+b print(a%M)