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