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

solve :: Int -> Int
solve n = minimum [ a + b | a <- [1 .. sqrt_n], let n_div_a = n `div` a, b <- [a .. n_div_a], a * b == n ] - 2
  where
    sqrt_n  = floor $ sqrt $ fromIntegral n