A, B = map(int, input().split()) count = A while count <= B: if (count % 3 == 0 or '3' in str(count)): print(count) else: pass count += 1