Scanf.scanf "%d %s" (fun n s ->
    let rec loop i cur mx =
        if i = n then Printf.printf "%d\n" mx else
            let cur = if s.[i] = 'I' then cur + 1 else cur - 1 in
            loop (i + 1) cur (max mx cur)
    in
    loop 0 0 0
)