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