function Main(input) {
  let result = input - 1
  for (i=1; i<(input/2); i++) {
    let tmp = input / i
    if (Math.round(tmp) === tmp) {
      if ((tmp + i -2) < result) result = tmp + i - 2
    }
  }
  console.log(result)
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));