https://www.acmicpc.net/problem/1699
import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner s=new Scanner(System.in);
int n=s.nextInt();
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;
}
}
}
System.out.print(arr[n]);
}
}