n,m = map(int,input().split()) a,b = 0,1 for _ in range(n-2): a,b = b,(a+b)%m print(b%m)