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

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