A, B = map(int, input().split()) for N in range(A, B + 1): if N % 3 == 0 or "3" in str(N): print(N)