a,b = map(int, input().split()) def calc(a,b): l=[] for i in range(a,b+1): if i%3==0: l.append(i) break m=i while 1: if (m%10==3) or (m==0): l.append(i) break m=int(m/10) return l for i in calc(a,b): print(i)