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 a = fst . foldl' f (-1,a)

f (c,s) b 
  | s*s'<0    = (c,s')
  | s>0       = (c+1+abs s',-1)
  | s<0       = (c+1+abs s',1)
  where
  s' = s+b
