import Control.Applicative
import Data.List

main :: IO ()
main = solve <$> readLn >>= print

solve :: Int -> Int
solve n = minimum $ unfoldr f 1
  where
    f i = if i * i > n then Nothing
          else if n `mod` i == 0 then Just (i + n `div` i - 2, i + 1)
               else f (i + 1)
