'use strict'

const Main = (input) => {
  const N = parseInt(input.trim())

  const divisors = []

  for (let i = 1; i <= Math.sqrt(N); i++) {
    if ((N % i) === 0) {
      divisors.push(i)
    }
  }

  const result = (N / Math.max.apply(null, divisors)) + Math.max.apply(null, divisors) - 2

  console.log(result)
  return result
}

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