from collections import defaultdict





def main():

    N = int(eval(input()))

    S = str(eval(input()))

    x = 0

    ans = 0

    for c in S:

        x += {"I": 1, "D": -1}[c]

        ans = max(ans, x)

    print(ans)





if __name__ == '__main__':

    main()

from collections import defaultdict





def main():

    N = int(eval(input()))

    S = eval(input())

    x = 0

    ans = 0

    for s in S:

        if s == "I":

            x += 1

        else:

            x -= 1

        ans = max(ans, x)

    print(ans)





if __name__ == '__main__':

    main()

from collections import defaultdict


def main():
    N = int(eval(input()))
    S = str(eval(input()))
    x = 0
    ans = 0
    for c in S:
        x += {"I": 1, "D": -1}[c]
        ans = max(ans, x)
    print(ans)


if __name__ == "__main__":
    main()

from collections import defaultdict


def main():
    N = int(eval(input()))
    S = eval(input())
    x = 0
    ans = 0
    for s in S:
        if s == "I":
            x += 1
        else:
            x -= 1
        ans = max(ans, x)
    print(ans)


if __name__ == "__main__":
    main()

-    S = str(eval(input())) +    S = eval(input()) -    for c in S: -        x += {"I": 1, "D": -1}[c] +    for s in S: +        if s == "I": +            x += 1 +        else: +            x -= 1