#include #define syosu(x) fixed< P; typedef pair pdd; typedef pair pll; typedef vector vi; typedef vector vvi; typedef vector vd; typedef vector vvd; typedef vector vl; typedef vector vvl; typedef vector vs; typedef vector

vp; typedef vector vvp; typedef vector vpll; typedef pair pip; typedef vector vip; const int inf=1<<30; const ll INF=1ll<<60; const double pi=acos(-1); const double eps=1e-9; const ll mod=1e9+7; const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0}; ll n,A=1,B=1,C=1,res=INF; vl a,b; vvl c; void dfs(int I){ if(I==a.size()){ res=min(res,A+B+C-3); return; } int N=b[I]; for(int i=0;i<=N;i++) for(int j=0;j<=N-i;j++){ A*=c[I][i];B*=c[I][j];C*=c[I][N-i-j]; if(A+B+C-3>n; ll N=n; for(ll i=2;i*i<=n;i++) if(n%i==0){ int t=0; while(n%i==0){ t++; n/=i; } a.push_back(i); b.push_back(t); } if(n){ a.push_back(n); b.push_back(1); } int S=a.size(); c=vvl(S); for(int i=0;i