v = list(map(int,input().split(" "))) A = v[0] B = v[1] for i in range(A,B+1): if i % 3 == 0: print(i) elif '3' in list(str(i)): print(i)