'use strict';

function main(stdin) {
  const input = stdin.split(' ').map(v => parseInt(v, 10));
  const N = input[0];

  const max = Math.ceil(Math.sqrt(N));
  let ans = 0;

  for (let i = 1; i <= max; ++i) {
    if (N % i == 0) ans = N / i + i - 2;
  }

  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim());