nlist = list(map(int, input().split())) i = nlist[0] while i <= nlist[1]: if i % 3 == 0 or str(i).find('3') != -1: print(str(i)) i += 1