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