a, b = map(int, input().split()) ans = [] for i in range(a, b+1): if "3" in str(i): ans.append(i) if i % 3 == 0: ans.append(i) for i in sorted(set(ans)): print(i)