a, b = map(int, input().split()) curr = a while curr <= b: if curr % 3 == 0: print(curr) elif '3' in str(curr): print(curr) curr += 1