A,B = map(int,input().split()) for i in [x for x in range(A,B + 1) if not x % 3 or "3" in str(x)]: print(i)