import Data.List

main :: IO ()
main = do
  l1 <- getLine
  let [n] = map read $ words l1 :: [Int]
      l = filter ((==0) . (mod n)) [1..truncate (sqrt $ fromInteger $ toInteger n)]
      m = maximum l
  print $ m + (n`div`m) - 2
