#include #include #include #include #include #include #include #include #include #include #pragma GCC optimize("O3") #pragma comment(linker, "STACK:36777216") using namespace std; using i64 = int64_t; constexpr i64 MOD = 1e9 + 7; using vi = vector; using vvi = vector; using vvvi = vector; vi tris; bool in(i64 a) { for (auto i: tris) { if (i == a) return true; } return false; } int main() { int n; cin >> n; for (i64 i = 1;; i++) { i64 t = i * (i + 1) / 2; if (t > 1e7) break; tris.push_back(t); } if (in(n)) { cout << 1 << endl; return 0; } for (auto i: tris) { i64 k = n - i; if (k >= 1 && in(k)) { cout << 2 << endl; return 0; } } cout << 3 << endl; }