main = do
    n <- readLn
    print $ solve n

solve :: Int -> Int
solve n = let ls = [(x*y,(x,y))|x<-[1..n],y<-[x..n]] in minimum $ products n ls

products :: Int -> [(Int,(Int,Int))] -> [Int]
products n [] = []
products n (x:xs)
    | n == (fst x) = (distance (snd x)) : products n xs
    | otherwise = products n xs

distance :: (Int,Int) -> Int
distance  (a,b) = a-1 + b-1