A,B = map(int,input().split()) ans=[] for n in range(A,B+1): if n%3==0: ans.append(n) elif "3" in str(n): ans.append(n) print(*ans,sep="\n")