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