a,b = map(int, input().split()) for n in range(a, b + 1): if n % 3 == 0 or str(n).find("3") >= 0: print(n)