main :: IO ()
main = do
  n <- readLn
  print $ ans n

ans :: Integer -> Integer
ans n = (n `div` x) + x - 2 where
  n' = ceiling . sqrt $ fromIntegral n
  func m = if n `mod` m == 0 then m else func (m-1)
  x = func n'