n = input().split(" ") n = list(map(int,n)) a = n[0] b = n[1] for i in range(a,b+1): if i % 3 == 0 or list(str(i)).count("3") > 0: print(i)