#include #include #include using namespace std; int main() { long n; cin>>n; unordered_set s; long res=n-1; for(long i=1; i*i<=n; ++i) { if (n%i) continue; auto m=n/i; if (s.count(m)) continue; s.insert(m); for(long j=1; j*j<=m; ++j) { if (m%j) continue; res=min(res, i-1+j-1+m/j-1); } } cout<