#include #include using namespace std; typedef long long ll; int main(){ ll N;cin>>N; ll T_MIN=N-1,T_MAX=N-1; vector v; ll N2=N; for(int i=2;i*i<=N;++i){ while(1){ if(N2==1) break; if(N2%i==0){ N2/=i; v.push_back(i); } else { break; } } } if(N2!=1) v.push_back(N2); if(v.size()==1){ // } else if(v.size()==2){ ll a=v[0]; ll b=v[1]; T_MIN=a-1+b-1; } else { for(int i=0;i