Option Strict On
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim N As Integer = NextInt()
        Dim S As String = NextString()

        Dim maximum_value As Integer = 0
        Dim cnt As Integer = 0

        For i As Integer = 0 To N - 1
            cnt += Calc(S(i))
            maximum_value = Math.Max(maximum_value, cnt)
        Next

        WriteLine(maximum_value)
    End Sub

    Function Calc(c As Char) As Integer
        Select Case c
            Case "I"c
                Return 1
            Case "D"c
                Return -1
            Case Else
                Return 0
        End Select
    End Function

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module
