mini,maxi=map(int,input().split()) n=[] for i in range(mini,maxi+1): if (i % 3 == 0) or ('3' in str(i)): n.append(i) for j in n: print(j)