solve :: Int -> String -> [Int]
solve i [] = [i]
solve i (s:ss) = i : solve r ss
  where r = i + if s == 'I' then 1 else -1

main :: IO ()
main = do
  getLine
  s <- getLine
  print . maximum $ solve 0 s