import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  (n : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  let
    k = until ((== 0) . (mod n)) pred . sq $ n
    l = n `div` k
  print $ pred k + pred l

sq :: Int -> Int
sq n = sq' 1 . succ $ n
  where
    sq' i j | j == succ i = i
            | m ^ 2 <= n = sq' m j
            | otherwise = sq' i m
      where
        m = (i + j) `div` 2

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n
