raw = input() str_num = raw.split() A = int(str_num[0]) B = int(str_num[1]) for i in range(A, B): if '3' in str(i): print(i) elif i % 3 == 0: print(i) else: pass