Self Love
After cashing in on his last caper, YouKnowWho stumbles upon a dusty tome titled
“Mirrors in the Square”. Each page whispers the name of a number that sees itself at the end of its square.
To unlock the vault of the Arithmancers, he needs the k-th such “self-loving” integer.
The guards? Just exponents and carries. The key? Your code. Don’t keep YouKnowWho waiting.
Input
Single integer k (1-indexed), asking for the k-th "self-loving" number.
Output
Print the k-th integer n such that n2 ends in n.
Sample Input
4
Sample Output
6
Explanation
The first 4 numbers are: 0, 1, 5, 6.