#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; int main() { int N; cin >> N; vector M; int k = 1; while (k * (k + 1) / 2 <= N) { M.push_back(k * (k + 1) / 2); ++k; } for (int i = 0; i < M.size(); ++i) { int a = M[i]; if (a == N) { cout << 1 << endl; return 0; } } for (int i = 0; i < M.size(); ++i) { int a = M[i]; for (int j = i; j < M.size(); ++j) { int b = M[j]; int c = a + b; if (c == N) { cout << 2 << endl; return 0; } } } cout << 3 << endl; return 0; }