U,T=map(int,input().split()) for i in range(U,T): if i%3==0: print(i) else: tex=str(i) for char in tex: if char=="3": print(i) break