isPrime :: Int -> Bool
isPrime n = loop n 2
    where
        loop :: Int -> Int -> Bool
        loop n i
            | n <= 1 = False
            | n `rem` i == 0 = False
            | n < i * i = True
            | otherwise = loop n (i + 1)

solve :: Int -> Int
solve n 
    | isPrime n = n - 1
    | s * s == n = s * 2 -2
    | otherwise = s * 2 - 1
    where
        s :: Int
        s = floor . sqrt . fromIntegral $ n


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