let (|>) x f = f x ;;
let n = Scanf.scanf "%d\n" (fun n -> n) ;;
let s = Scanf.scanf "%s\n" (fun s -> s) ;;

let string_to_list str =
  let id_to_int c =
    if c = 'I' then 1
    else -1
  in
  let rec loop idx arr=
    if idx = -1 then arr
    else loop (idx-1) ((id_to_int (String.get str idx))::arr)
  in
  loop (n-1) []
;;

let solve arr =
  let rec sim ma v arr = 
    match arr with
    | [] -> ma
    | h::t ->
      let w = v + h in
      let new_max = max ma w in
      sim new_max w t
  in
  sim 0 0 arr
;;

let () =
  s
  |> string_to_list
  |> solve
  |> Printf.printf "%d\n"
