solve :: Int -> Int -> String -> Int
solve n _ [] = n
solve n m ('I':xs) = solve (max n (m + 1)) (m + 1) xs
solve n m ('D':xs) = solve n (m - 1) xs
  
main = getContents >>= putStrLn . show . (solve 0 0) . last . words