a, b = [int(i) for i in input().split()] for i in range(a, b + 1): l = [int(j) for j in str(i)] if 3 in l or i % 3 == 0: print(i)