https://www.acmicpc.net/problem/1699
using System;
class Program
{
static void Main() {
string s=Console.ReadLine();
int n=int.Parse(s);
int[] arr=new int[n+1];
for(int i=0;i<=n;i++) arr[i]=i;
for(int i=1;i<=n;i++){
for(int j=1;j*j<=i;j++){
if(arr[i]>arr[i-j*j]+1){
arr[i]=arr[i-j*j]+1;
}
}
}
Console.Write(arr[n]);
}
}