2347. 
Let be a positive integer. Bernardo and Silvia take turns writing and erasing numbers on a blackboard as follows: Bernardo starts by writing the smallest perfect square with digits. Every time Bernardo writes a number, Silvia erases the last digits of it. Bernardo then writes the next perfect square, Silvia erases the last digits of it, and this process continues until the last two numbers that remain on the board differ by at least 2. Let be the smallest positive integer not written on the board. For example, if , then the numbers that Bernardo writes are , and the numbers showing on the board after Silvia erases are and , and thus . What is the sum of the digits of ?
This problem is copyrighted by the American Mathematics Competitions.

Instructions for entering answers:
For questions or comments, please email markan@eudelic.com.
Try our new, free contest math practice test. All new, neverseenbefore problems.
I offer online AMC/AIME classes periodically. Join the mailing list to be informed next time they're offered.
Private coaching is also available.