import qualified Data.ByteString.Char8 as C
import Data.List

main = C.interact $ put . sol . get

get = unfoldr (C.readInt . C.dropWhile (==' ')) . last . C.lines

put = C.pack . show

sol = min <$> g (-1) <*> g 1

g d = (\(c,_,_) -> c) . foldl' f (0,0,d)

f (c,s,d) a 
  | d*s'>0    = (c,s',-d)
  | otherwise = (c+1+abs s',d,-d)
  where
  s' = s+a