solve cs = if x < 0 then 0 else x
  where
    l = [if c == 'I' then 1 else -1 | c <- cs]
    is = [1..length l]
    x = maximum [sum (take i l) | i <- is]

main = getContents >>= print . solve . last . lines
