a,b = map(int, input().split()) ans = [] for num in range(a, b+1): if '3' in str(num): ans.append(num) elif num % 3 == 0: ans.append(num) for v in ans: print(v)