#include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; int main(){ int N; cin >> N; vector v; { int k = 1; while(true){ ll x = k * (ll)(k+1) / 2; v.push_back(x); if(x > N) break; k++; } } rep(i,v.size()){ if(N == v[i]){ cout << 1 << endl; return 0; } } rep(i,v.size()){ rep(j,v.size()){ if(N == v[i] + v[j]){ cout << 2 << endl; return 0; } } } cout << 3 << endl; return 0; }