import math a,b = map(int, input().split()) x = 10 t = 10 for i in range(a, b + 1): if i % 3 == 0: print(i) while x < 1000000000: if math.floor(i / x) == 3: print(i) x = x * 10 while t < 1000000000: if i % t == 3: print(i) t = t * 10