#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define rep(i,n) for(int i = 0;i<((int)(n));i++) #define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++) #define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--) #define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--) typedef long long ll; typedef pair mp; ll mod = 1e9+7; ll inf = 1e18; //AC int main(void){ ll n,ans=0; cin>>n; vector v; reg(i,1,1e9){ if(i*(i+1)/2>n)break; if(i*(i+1)/2==n){ ans=1; break; } v.push_back(i*(i+1)/2); } if(ans==0){ //全ての組み合わせを作る. set s; rep(i,v.size()){ rep(j,i+1){ s.insert(v[i]+v[j]); } } if(s.count(n)>0){ ans=2; }else{ ans=3; } } cout<