solve :: Int -> Int
solve n = minimum $ map f [1..lim]
    where
        lim :: Int
        lim = floor . sqrt . fromIntegral $ n
        f :: Int -> Int
        f i
            | r == 0 = i + q - 2
            | otherwise = 10^13
                where
                    (q,r) = divMod n i

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