A,B=map(int,input().split()) for i in range(A,B+1): d=str(i) if i%3==0: print(i) else: for j in range(0,len(d)): if int(d[j])==3: print(i) break