a, b = [int(x) for x in input().split()] for n in range(a, b + 1): if (n % 3 == 0): print(n) else: for keta in list(str(n)): if (keta == '3'): print(n)