A, B = map(int, input().split()) i = A while i <= B: if i % 3 == 0: print(i) else: l = [int(x) for x in list(str(i))] x = len(l) - 1 y = 0 while y <= x: if l[y] == 3: print(i) break else: y += 1 i += 1