# ABC052B - Increment Decrement

_ = int(eval(input()))

s = eval(input())

x = 0

lst = [0]

for i in s:

    if i == "I":

        x += 1

    else:

        x -= 1

    lst.append(x)

print((max(lst)))
# ABC052B - Increment Decrement

def main():

    _, S = tuple(eval(input()) for _ in range(2))

    ans, x = [0], 0

    for i in S:

        x += 1 if i == "I" else -1

        ans += [x]

    print((max(ans)))





if __name__ == "__main__":

    main()
# ABC052B - Increment Decrement
_ = int(eval(input()))
s = eval(input())
x = 0
lst = [0]
for i in s:
    if i == "I":
        x += 1
    else:
        x -= 1
    lst.append(x)
print((max(lst)))

# ABC052B - Increment Decrement
def main():
    _, S = tuple(eval(input()) for _ in range(2))
    ans, x = [0], 0
    for i in S:
        x += 1 if i == "I" else -1
        ans += [x]
    print((max(ans)))


if __name__ == "__main__":
    main()

-_ = int(eval(input())) -s = eval(input()) -x = 0 -lst = [0] -for i in s: -    if i == "I": -        x += 1 -    else: -        x -= 1 -    lst.append(x) -print((max(lst))) +def main(): +    _, S = tuple(eval(input()) for _ in range(2)) +    ans, x = [0], 0 +    for i in S: +        x += 1 if i == "I" else -1 +        ans += [x] +    print((max(ans))) + + +if __name__ == "__main__": +    main()