A, B = map(int, input().split()) for x in range(A, B+1): if x % 3 == 0 or 3 in list(map(int, str(x))): print(x)