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