n=int(input()) p=1<=n<=10**5 if p: for i in range(1,n+1): p1=i%4!=0 p2='4' not in str(i) if p1*p2:print(i) else:print('超出范围')