A, B = map(int,input().split()) integer = [ i for i in range(A,B+1) ] for i in integer: if i % 3 == 0: print(i) continue if i > 9: s = str(i) for j in s: if j == '3': print(i) break