input();x,r=0,0
for i in input():
  if i=='I': x+=1
  else: x-=1
  r=max(r,x)
print(r)
57504e7ac8c0591a7f28c5faca892c4545127e59
<mask token>

input()
<mask token>
for i in input():
    if i == 'I':
        x += 1
    else:
        x -= 1
    r = max(r, x)
print(r)

input()
x, r = 0, 0
for i in input():
    if i == 'I':
        x += 1
    else:
        x -= 1
    r = max(r, x)
print(r)

input();x,r=0,0
for i in input():
  if i=='I': x+=1
  else: x-=1
  r=max(r,x)
print(r)