{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE Unsafe #-}
{-# LANGUAGE RecordWildCards #-}

import Data.Bits
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.ByteString.Lazy.Char8 as BSL
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IMS
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS
import qualified Data.Array.IArray as A
import qualified Data.Array.MArray.Safe as A
import qualified Data.Array.MArray as A
import Data.Array (Array)
import Data.Array.Unboxed (UArray)
import Data.Array.IArray (IArray)
import Data.Array.MArray.Safe (MArray)
import Data.Array.IO.Safe (IOArray, IOUArray)
import Data.Array.ST.Safe (STArray, STUArray, runSTArray, runSTUArray)
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import Control.Monad
import Control.Monad.ST
-- import Control.Monad.ST.Safe
import Control.Applicative
import Data.Maybe
import Data.Tuple
import Data.Ord
import Control.Monad.State.Strict
import Data.Int
import System.IO
import Data.Function

data Bulb = On {-# UNPACK #-} !Int | Off {-# UNPACK #-} !Int deriving (Eq)

instance Ord Bulb where
  compare (On x) (On y) = compare x y
  compare (On x) (Off y) | x <= y    = LT
                         | otherwise = GT
  compare (Off x) (On y) | x < y     = LT
                         | otherwise = GT
  compare (Off x) (Off y) = compare x y

main :: IO ()
main = do
  getLine
  ls <- flip (zipWith $ flip ($)) (cycle [On,Off]) .
          unfoldr (BSL.readInt . BSL.dropWhile (<'-')) <$> BSL.getContents
  let onoff = map (\case ls@(On _ : _) -> length ls
                         ls@(Off _ : _) -> -length ls) $ group $ sort ls
  print $ maximum $ scanl' (+) 0 onoff

