f = input() s_f = f.split() A = int(s_f[0]) B = int(s_f[1]) for v in range(A, B+1): if '3' in str(v) or v % 3 == 0: print(v)