A,B = map(int, raw_input().split()) for i in range(A,B+1): if i % 3 == 0: print i else: t = str(i) for j in range(len(t)): if t[j] == '3': print i