A, B = map(int, input().split()) def is_multi3(x): return x % 3 == 0 def is_in3(x): return '3' in list(str(x)) for i in range(A, B + 1): if is_multi3(i): print(i) continue if is_in3(i): print(i)