a,b=map(int,input().split()) for x in range(a,b+1):[print(x) if x%3==0 or '3' in str(x) else '']