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