#include #include #include using namespace std; vector getTriangleNums() { vector v; int k = 0; while (k*(k+1) <= 20000000) { v.push_back(k*(k+1)/2); ++k; } return v; } int main(int argc, char *argv[]) { int n; cin >> n; vector x = getTriangleNums(); int ret = 3; for (int i = 0; i < x.size(); i++) { for (int j = 0; j < x.size(); j++) { int a = x[i]; int b = x[j]; int c = n - a - b; if (binary_search(x.begin(), x.end(), c)) { int tmp = (a > 0) + (b > 0) + (c > 0); ret = min(ret, tmp); } } } cout << ret << endl; return 0; }