#include using namespace std; #define rep(i,a,b) for(int i=a;i> n; int i = 0; while(i*(i+1)/2 <= n) i++; n -= i*(i-1)/2; int dp[n+1]; rep(i,0,n+1) dp[i] = i; rep(i,2,1000){ rep(j,0,n+1){ if(j + (i*(i+1)/2) < n+1){ dp[j + (i*(i+1)/2)] = min(dp[j+(i*(i+1)/2)], dp[j] + 1); } } } cout << dp[n] + 1 << endl; }