main = do
    n <- read <$> getLine
    print $ solver n

solver n = head
    [ n `div` x + x - 2
    | x <- enumFromThenTo (sqrtInt n) (pred . sqrtInt $ n) 1
    , n `mod` x == 0
    ]

sqrtInt = floor . sqrt . fromIntegral