#include<bits/stdc++.h>
using namespace std;

int main(){
  int64_t n,ans;
  cin>> n;
  for (int i=sqrt(n); i>0; i--){
    if (n%i==0){
      ans=i+n/i-2;
      break;
    }
  }
  cout<< ans <<endl;
}