x,y = [int(i) for i in input().split()] for j in range(x,y + 1): if j % 3 == 0: print(j) elif str(j).find("3") >= 0: print(j)