Find the largest natural number which does not exceed a given M and its decimal representation coincides with the last digit of the square.
A positive integer M (1 ≤ M ≤ 1000000000).
The answer to the problem.