# No.207 世界のなんとか def main(): A, B = tuple(map(int, input().rstrip().split())) ans = [i for i in range(A, B + 1) if i % 3 == 0 or "3" in str(i)] print(*ans, sep="\n") if __name__ == "__main__": main()