Minimum number of perfect squares

Given an integer n, you are asked to find as few perfect squares (1, 4, 9, 16, 25, 36, etc.) as possible that sum up to n. How many perfect squares would you pick?

Input

The input contains a single integer n (1 ≤ n ≤ 60000).

Output

The program should print the minimum number of perfect squares you would pick.

Examples

Input
Output
344
3

Explanation

 

Constraints

Time limit: 9 seconds

Memory limit: 512 MB

Output limit: 1 MB

To check your solution you need to sign in
Sign in to continue