Hide

Problem F
Hexaphobic Square

/problems/hexaphobicsquare/file/statement/en/img-0001.png
Sketched numeral - 6 by Firkin on openclipart.org, CC0.

As chief product officer for the Hexaphobic Cipher Product Company, it is your job to come up with the next great product to sell to your customers. Of course, the main reason your customers come to the HCPC is that they are afraid of the number 6, but your next product needs something extra to distinguish it. Since people have lately been spending a lot of time obsessing over round things like the sun and moon, you suspect that after the eclipse, fashion will swing back in the other direction, towards things that are square instead of round. Thus, you determine to choose a square number for your next product (which, of course, also does not contain the digit $6$).

Input

The input consists of a single positive integer $n$ ($0 \leq n \leq 1\, 000$).

Output

Output the smallest integer greater than $n$ whose square does not contain the digit $6$ when written in base $10$.

Sample Input 1 Sample Output 1
3
5
Sample Input 2 Sample Output 2
28
29

Please log in to submit a solution to this problem

Log in