import CoreFoundation
let arr=readLine()!.characters.split{$0==" "}.map{Int(String($0))!}

let n = arr[0]

var move = 0
var min = n 
for i in 1...Int(sqrt(Double(n))) {
  if( ( n % i ) == 0 ) {
    if( ( n / i ) + i - 2 < min ) {
      min = ( n / i ) + i - 2
    }
  }
}

print( min )