#include using namespace std; class en{ int N; int mine[100000]; int ans; int MAX; int p; public: en(); void show(); void max(); void cal(); }; en::en() { int n; cin >> n; N = n; } void en::max() { int kane = 1; int j = 2; int i = 0; for(i = 0; ;i++){ if(N < mine[i-1]) { MAX = mine[i-2]; p = i - 2; break; } mine[i] = kane; kane = kane + j; j++; } } void en::cal() { int saihu; int P = p; saihu = N; int tmp, pre = 0; int i = 0; while(1){ while(1){ tmp = saihu - mine[P]; if(tmp < 0){ P = P-1; } else if(tmp > 0){ pre++; saihu = saihu - mine[P]; } else{ pre++; break; } if(ans == pre){ break; } } i++; if(i == 1) ans = pre; P = p - i; if(ans > pre) ans = pre; pre = 0; saihu = N; if(P == -1) break; } } void en::show() { cout << ans << "\n"; } int main(){ en kane; kane.max(); kane.cal(); kane.show(); return 0; }