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