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