A,B=map(int,input().split()) for i in range(A,B+1): f=False s = str(i) for j in range(0,len(s)): if s[j]=="3": f=True break if i%3 == 0 or f: print(i)