def f(n): if n%3==0: return 1 if str(n).count("3")>0: return 1 return 0 a,b=map(int,input().split()) for i in range(a,b+1): if f(i): print(i)