main :: IO()
main = do
  n <- readLn
  putStrLn $ show $ solve n

solve :: Int -> Int
solve n = minimum $ map addPairs $ filter ((==0) . (n `mod`)) $ listsUntilSqrtN n
  where
    addPairs d = d + (n `div` d) - 2
  
listsUntilSqrtN :: Int -> [Int]
listsUntilSqrtN n = let sqrtN = ceiling $ sqrt $ fromIntegral n
                      in [1..sqrtN]