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