let array_of_string s = Array.init (String.length s) (fun i -> s.[i])

let () = Scanf.scanf "%d\n%s\n" @@ fun _ s ->
  array_of_string s
  |> Array.fold_left (fun (acc, curr) c ->
      let curr =
        curr + if c = 'I' then 1 else (-1) in
      (max acc curr, curr)) (0, 0)
  |> fst
  |> Printf.printf "%d\n"
