a, b = list(map(int, input().split())) for x in range(a, b + 1): if x % 3 == 0 or str(x).count('3') > 0: print(x)