A,B = map(int,input().split()) def nabeatsu(n,x): if (x//(10**n))%10-3 == 0 or x%3 == 0: return True for i in range(A,B+1): for k in range(0,10): if nabeatsu(k,i) == True: print(i) break