solve :: Int -> String -> [Int]
solve _ [] = 0 : []
solve n (x:xs)
  | x == 'I' = (n + 1) : solve (n + 1) xs
  | otherwise = (n - 1) : solve (n - 1) xs

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