n=int(input())
for i in range(1,n+1):
    if '4' not in str(i) and i%4!=0:
        print(i)