[a, b] = [int(x) for x in input().split(' ')] ret = [] for i in range(a, b + 1): if i%3 == 0 or '3' in str(i): ret.append(i) for i in sorted(ret): print(i)