n=int(input()) for i in range(1,n+1): if i%3==0: for j in str(i): if j=='5': print(int(i))