A,B = map(int, input().split()) for i in range(A, B + 1): save = i boolean = [] while i > 1: boolean.append(i%10) i = i//10 if save % 3 == 0: print(save) else: for n in boolean: if n == 3: print(save)