This problem is a programming version of Problem 171 from projecteuler.net
For a positive integer , let be the sum of the squares of the digits (in base ) of , e.g.
,
,
Find the sum of all , , such that is a perfect square modulo .
Input Format
The first line of input contains the only integer .
Constraints
Output Format
Output the only integer which is the answer for the problem.
Sample Input 0
100
Sample Output 0
826
Explanation 0
You have to sum up following numbers: .