k=int(input()) for i in range(10000, 30001): a=i//100 b=(i%10000)//10 c=i%1000 if a%k==0 and b%k==0 and c%k==0: print(i)