Problem:
 Score : 200 points    Problem Statement You have an integer variable x .
Initially, x=0 .  Some person gave you a string S of length N , and using the string you performed the following operation N times.
In the i -th operation, you incremented the value of x by 1 if S_i= I , and decremented the value of x by 1 if S_i= D .  Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).      Constraints  1≤N≤100  |S|=N  No characters except I and D occur in S .         Input The input is given from Standard Input in the following format:  N  S       Output Print the maximum value taken by x during the operations.        Sample Input 1 5
IIDID      Sample Output 1 2  After each operation, the value of x becomes 1 , 2 , 1 , 2 and 1 , respectively. Thus, the output should be 2 , the maximum value.       Sample Input 2 7
DDIDDII      Sample Output 2 0  The initial value x=0 is the maximum value taken by x , thus the output should be 0 .

Solution (Python):

n=int(input())
s=list(str(input()))
ans=0
h=[0]
for i in range(n):
    if  s[i]=="I":
        ans+=1
        h.append(ans)
    elif s[i]=="D":
        ans-=1
        h.append(ans)
print(max(h))

Solution (Python):
n=int(input())
s=input()
A=[0]
a=0
for i in s:
  if i=="I":
    a+=1
  else:
    a-=1
  A.append(a)
print(max(A))

Solution (Python):
N = int(input())
S = input()
x = 0
n = 0
for s in S:
    if s == "I":
        x += 1
    else:
        x -= 1
    n = max(n, x)
print(n)

Solution (Python):
n = int(input())
s = input()

x=0
ans=0

for i in range(n):
    if(s[i]=="I"):
        x+=1
    else:
        x-=1
    ans=max(ans, x)

print(ans)

Solution (Python):
n = int(input())
s =input()
x = 0
xmax = 0
for i in s:
    if i =='I':
        x +=1 
        xmax = max(xmax,x)
    else:
        x -=1
print(xmax)

Solution (Python):
N = int(input())
tex=list(input())
max=0
cur=0
for i in range(N):
  if tex[i]=="I":
    cur+=1
    if cur>max:
      max=cur
  else:
    cur-=1
print(max)

Solution (Python):
num = int(input())
word = input()

maxi = 0
x = 0
for i in word:
  if i=='I': x+=1
  else: x-=1
  if x>maxi: maxi=x

print(maxi)

Solution (Python):
n = int(input())

res = 0
sum = 0
for s in input():
    if "I" == s:
        sum+=1
    elif "D" == s:
        sum-=1
    if sum > res: res = sum

print(res)

Solution (Python):
n = int(input())
s = input().rstrip()
x = 0
ans = 0
for c in s:
    if c == "I":
        x+=1
    elif c == "D":
        x-=1
    ans = max(ans, x)

print(ans)

Solution (Python):
n = int(input())
s = input()

x = [0]

for i in s:
  if i == "I":
    x.append(x[-1] + 1)
  else:
    x.append(x[-1] - 1)

print(max(x))

Solution (Python):
n = int(input())
s = input()
cnt,x,y,m=0,0,0,0

for i in range(n):
    if s[i] == "I":
        cnt += 1
        m = max(cnt,m)

    else:
        cnt -= 1

print(m)

Solution (Python):
n = int(input())
x = Max = 0
for s in input():
    x += 1 if s == 'I' else -1
    Max = max(Max, x)
    
print (Max)

Solution (Python):
n=input()
s=input()
while "DI" in s:
    s=s.replace("DI","")
print(s.count("I"))

Solution (Python):




def main():
    x = 0
    N = input()
    S = raw_input()
    
    
    x_max = x
    for ope  in S:
        if ope == 'I':
            x = x + 1
        elif ope == 'D':
            x = x -1
        x_max = max(x,x_max)

    print(x_max)

if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
S = input()
x_list = [0]
x = 0
for s in S:
    if s == "I":
        x += 1
        x_list.append(x)
    elif s == "D":
        x -= 1
print(max(x_list))

Solution (Python):
import sys

def main():
    input = sys.stdin.readline
    N = int(input())
    S = str(input().strip())

    A =[0 for _ in range(N+1)]
    for i in range(1, N+1):
        if S[i-1] == 'I':
            A[i] = A[i-1] + 1
        else:
            A[i] = A[i-1] -1

    return max(A)


if __name__ == '__main__':
    print(main())

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    s = input()
    x = 0
    maxx = 0
    for i in s:
        if i == 'D':
            x -= 1
        if i == 'I':
            x += 1
        
        maxx = max(maxx, x)
    
    print(maxx)

solve()

Solution (Python):
n=int(input())
s=input()
res=0
ans=0
for i in range(n):
  if s[i]=='I':
    tmp=res+1
  else:
    tmp=res-1
  if tmp>ans:
    ans=tmp
  res=tmp
print(ans)

Solution (Python):

N=int(input())
S=list(str(input()))
ans=0
ansl=[]
for i in range(N):
    if S[i]=="I":
        ans+=1
    else:
        ans-=1
    ansl.append(ans)


ansl.append(0)
print(max(ansl))

Solution (Python):

N=int(input())
S=list(str(input()))
ans=0
ansl=[]
for i in range(N):
    if S[i]=="I":
        ans+=1
    elif S[i]=="D":
        ans-=1
    ansl.append(ans)


ansl.append(0)
print(max(ansl))

Solution (Python):
N = int(input())
S = input()

res = 0
tmp = 0
for s in S:
    if s == "I":
        tmp += 1
    if s == "D":
        tmp -= 1
    res = max(tmp,res)

print(res)

Solution (Python):
N=int(input())
S=input()
ans=0
key=0
for i in range(len(S)):
    if S[i]=='I':
        key+=1
    else:
        key-=1
    ans=max(ans,key)
        
print(ans)

Solution (Python):
N = int(input())
S = str(input())

check = 0
ans = 0
for s in S:
    if s == "I":
        check += 1
    if s == "D":
        check -= 1
    ans = max(ans, check)
print(ans)

Solution (Python):
N=int(input())

S=input()

x=0
X=[0]

for s in S:
    if s=='I':
        x+=1
    if s=='D':
        x-=1
    X.append(x)

print(max(X))

Solution (Python):
n=int(input())
max_x=0
x=0
for i in input():
	if i=='I':
		x+=1
	else:
		x-=1
	max_x=max(max_x,x)
print(max_x)

Solution (Python):
from functools import reduce

def main():
    
    
    
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    

    N = int(input().rstrip())
    S = list(_ for _ in input())
    x = 0
    max_x = 0
    for s in S:        
        if s == 'I':
            x += 1
        elif s == 'D':
            x += -1
        max_x = max(x,max_x)
    print(max_x)
    
if __name__ == '__main__':
    main()

Solution (Python):
x = 0
N = int(input())
S = input()
ans = []
ans.append(x)
for i in range(N):
    if S[i] == "I":
        x += 1
    else:
        x -= 1
    ans.append(x)
print(max(ans))

Solution (Python):
N = int(input())
S = input()
ans = [0]
x = 0
for i in range(N):
    if S[i] == 'I':
        x += 1
        ans.append(x)
    else:
        x -= 1
        ans.append(x)
print(max(ans))

Solution (Python):
N = int(input())
s = input()
ans = 0
x = 0
for c in s:
    if c == 'I':
        x += 1
    else:
        x -= 1
    if x > ans:
        ans = x
print(ans)

Solution (Python):
n=int(input())
s=input()
x=0
list=[]
for i in range(n):
  if s[i]=='I':
    x+=1
  else:
    x-=1
  list.append(x)
print(sorted(list)[-1] if sorted(list)[-1]>=0 else 0)

Solution (Python):
input()
x,mx=0,0
for w in input():
  
  x+=1 if w=='I' else -1
  mx = max(x,mx)
print(mx)

Solution (Python):
n = int(input())
cnt = 0
ch = 0
*w, = map(str,input().split())

for i in w:
  for j in i:
    
    if j == 'I':
      cnt+=1
    elif j == 'D':
      cnt-=1
    if cnt > ch:
      ch = cnt
print(ch)

Solution (Python):
n = int(input())
s = input()
curr = 0
ans = 0
for i in s:
    if i == 'I': curr += 1
    if i == 'D': curr -= 1
    ans = max(curr, ans)
print(ans)

Solution (Python):
_,t=open(0);a=b=0
for x in t:b+=x>'D'or-1;a=max(a,b)
print(a)

Solution (Python):
n=input()
s=input();x,a=0,0
for i in s:
	x += 1 if i=='I' else -1
	a=max(a,x)
print(a)

Solution (Python):
N = int(input())
S = list(input())
x = 0
x_list = [0]
for i in S:
    if (i == "I"):
        x += 1
    else:
        x -= 1
    x_list.append(x)
print(max(x_list))

Solution (Python):
N = int(input())
S = input()

x = 0
ans = 0
for i in range(N):
	if S[i:i+1]=='I':
		x += 1
		ans = max(ans, x)
	elif S[i:i+1]=='D':
		x -= 1

print(ans)

Solution (Python):
num = int(input())
S = list(input())


ans = 0
total = 0
for n in S:
  if n == "I":
    total += 1
  elif n == "D":
    total -= 1
  if total > ans:
    ans = total

print(ans)

Solution (Python):
N = int(input())
S = input()
x = 0
ans = 0
for i in range(N):
  if S[i] == "I":
    x += 1
  else:
    x -= 1
  ans = max(ans,x)
print(ans)

Solution (Python):
n=int(input())
b=0
t=0
for c in input():
    if c == 'I':
        t += 1
    else:
        t -= 1
    if t > b:
        b = t
print(b)

Solution (Python):
n = int(input())
s = input()
x = 0
m = 0
for ch in s:
    if ch == 'I':
        x += 1
        if m < x:
            m = x
    else:
        x -= 1
        if m < x:
            m = x
print(m)

Solution (Python):
N = int(input())
S = input()

L = [0]
for s in S:
    if s == 'I':
        L.append(L[-1]+1)
    else:
        L.append(L[-1]-1)

print(max(L))

Solution (Python):
def increment_decrement(N: int, S: str)->int:
    x, max_x = 0, 0
    for c in S:
        if c == 'I':
            x += 1
            max_x = max(max_x, x)
        else:
            x -= 1
    return max_x


if __name__ == "__main__":
    N = int(input())
    S = input()
    ans = increment_decrement(N, S)
    print(ans)

Solution (Python):
from itertools import accumulate
n = input()
xs = list(input())
ys = [0]

for x in xs:
    if x == 'I':
        ys.append(1)
    else:
        ys.append(-1)

ans = max(list(accumulate(ys)))
print(ans)

Solution (Python):
n=int(input())
hoge=list(input())
ans=0
now=0
for i in range(n):
  if(hoge[i]=="I"):
    now+=1
  else:
    now+=-1
  
  if(now>ans):
    ans=now
    
print(ans)

Solution (Python):
n = int(input())
s = input()
ans = 0
m = 0
for i in range(n):
    if s[i] == 'I':
        ans += 1
    elif s[i] == 'D':
        ans -= 1
    m = max(ans, m)
print(m)

Solution (Python):
N = int(input())
a = list(input())

b = 0
x = [0]
for i in a:
    if i == "I":
        b +=1
        x.append(b)
    else:
        b -= 1
        x.append(b)
print(max(x))

Solution (Python):
def INSTR():
	return input()

def INNUM():
	return int(INSTR())

def INSTR_S():
	return INSTR().split()

def INNUM_S():
	return map(int, INSTR_S())

def INSTR_SM(n):
	return [tuple(INSTR_S()) for _ in range(n)]

def INNUM_SM(n):
	return [tuple(INNUM_S()) for _ in range(n)]

N = INNUM()
S = list(INSTR())
x = xmax = 0
for s in S:
	x += 1 if s == "I" else -1
	xmax = max(xmax, x)
print(xmax)

Solution (Python):
n = int(input())
s = list(input())
c = 0
a = [0]
for s_ in s:
    if s_ == "I":
        c += 1
        a.append(c)
    else:
        c -= 1
        a.append(c)
print(max(a))

Solution (Python):
N = int(input())
S = input()

x = 0
nums = [0]
for i in S:
    if i == 'I':
        x += 1
        nums.append(x)
    else:
        x -= 1
        nums.append(x)
print(max(nums))

Solution (Python):

from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007


"""
a,b,c,d = LI()
print(max(a*b,c*d))
"""

n = I()
s = S()
ans = 0
x = 0
for i in s:
    if i == "I":x += 1
    else:x-=1
    ans = max(ans,x)
print(ans)

"""
def factor(n):
    i = 2
    m = n
    while m >= i:
        while m%i == 0:
            m //= i
            d[i] += 1
            d[i] %= mod
            if m < i:break
        i += 1
n = I()
d = defaultdict(int)
for i in range(2,n+1):
    factor(i)
ans = 1
for i in d.values():
    ans *= i+1
    ans %= mod
print(ans)
"""


"""
n,a,b = LI()
x = LI()
ans = 0
for i in range(n-1):
    if a*(x[i+1]-x[i]) > b:
        ans += b
    else:
        ans += a*(x[i+1]-x[i])
print(ans)
"""

Solution (Python):
from sys import stdin
ans = [0]
x = 0
n = int(stdin.readline())
for i, c in enumerate(list(stdin.readline())):
    if c == 'I':
        x += 1
        ans.append(x)
    else:
        x -= 1
print(max(ans))

Solution (Python):
N=int(input())
S=str(input())
x=0
M=0
for i in range(N):
    si=S[i]
    if si=='I':
        x+=1
        if M<x:
            M=x
    else:
        x-=1
print(M)

Solution (Python):

N = int(input())
S = input()

I_count = [i for i, x in enumerate(S) if x == 'I']
D_count = [i for i, x in enumerate(S) if x == 'D']

tmp = [0] * N
for i in I_count:
    tmp[i] = 1
for i in D_count:
    tmp[i] = -1

ans = 0
List = []
for i in range(N):
    ans += tmp[i]
    List.append(ans)

print(max(0, max(List)))

Solution (Python):
N = int(input())
S = input()
judge = {"I":True, "D":False}
x = 0
ans = 0
for i in S:
    if judge[i]:
        x += 1
        ans = max(ans, x)
    else:
        x -= 1

print(ans)

Solution (Python):
n=int(input())
s=input()
ans=0
now=0
for c in s:
    now+= 1 if c=='I' else -1
    ans=max(ans,now)
print(ans)

Solution (Python):
n = int(input())
s = input()
x = 0
a = [0]
for k in s:
    if k == 'I':
        x += 1
    else:
        x -= 1
    a.append(x)
print(max(a))

Solution (Python):


n = int(input())
s = list(input())

x = 0
max_x = 0

for i in range(len(s)):
    if s[i] == "I":
        x += 1
    elif s[i] == "D":
        x -= 1
    max_x = max(max_x,x)

print(max_x)

Solution (Python):
N = int(input())
S = input()

x = 0
ans = 0

for i in range(N):
  pre_x = x
  if S[i] == "I":
    x += 1
  else:
    x -= 1
  ans = max(x, ans)
  
print(ans)

Solution (Python):
x=0
curmax=0
input()
S=list(input())
for i in S:
    if i=="I":
        x+=1
        curmax=max(curmax,x)
    else:
        x-=1
print(curmax)

Solution (Python):
n = int(input())
s = input()

res = 0
now = 0
for i in range(n):
    if s[i] == "I":
        now += 1
    else:
        now -= 1

    res = max(res,now)

print(res)

Solution (Python):
n = int(input())
s = input()
cnt = 0
res = 0
for i in s:
    if i=="I":
        cnt += 1
    elif i=="D":
        cnt -= 1
    res = max(res,cnt)
print(res)

Solution (Python):
n=int(input())
Ans=[0]
ans=0
s=list(input())
for i in range(n):
  if s[i]=='I':
    ans+=1
    Ans.append(ans)
  else:
    ans-=1
    Ans.append(ans)
print(max(Ans))

Solution (Python):
N = int(input())
S = list(map(str, input()))

val = 0
X = [val]
for i in range(N):
    if S[i] == "I":
        val += 1
    else:
        val -= 1
    X.append(val)
print(max(X))

Solution (Python):
N = int(input())
S = input()
x = 0
ans = 0

for s in S:
    if s == 'I':
        x += 1
    else:
        x -= 1
    ans = max(ans, x)
print(ans)

Solution (Python):
n = int(input())
s = input()

max = 0
x = 0

for i in range(n):
    if s[i] == 'I':
        x+=1
    if s[i] == 'D':
        x-=1
    
    if x > max:
        max = x
    
print(max)

Solution (Python):

N =int(input())
S =str(input())
x = 0
max_x =0
for s in S:
    if s =="I":
        x +=1
    else:
        x -=1
    if x > max_x:
        max_x = x
print(max_x)

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


if __name__ == "__main__":
    main()

Solution (Python):
n,s,max,x=int(input()),input(),0,0
for i in range(n):
  if s[i]=="I":x+=1
  else:x-=1
  if max<x:max=x
print(max)

Solution (Python):
N = int(input())
S = [i for i in input()]
anss=[0]
ans=0
for s in S:
    if s=="I":
        ans+=1
        anss.append(ans)
    elif s=="D":
        ans-=1
        anss.append(ans)
print(max(anss))

Solution (Python):
N = int(input())
S = str(input())
count = ans = 0
for i in range(0,N,1):
    if S[i] == "I":
        count += 1
    else:
        count -= 1
    if ans <= count:
        ans = count
print(ans)

Solution (Python):
n = int(input())
s = list(input())

x = 0
maxNum = 0

for i in range(n):
    if s[i] == "I":
        x += 1
    elif s[i] == "D":
        x -= 1
    if maxNum <= x:
        maxNum = x
print(maxNum)

Solution (Python):
x=0
n=int(input())
s=input()
l=[0]
for i in range(n):
    if s[i]=="I":
        x+=1
    elif s[i]=="D":
        x-=1
    l.append(x)
print(max(l))

Solution (Python):
n=int(input())
l=list(input())
s=0
lis=[0]
for i in range(n):
  if l[i]=="D":
    s+=-1
    lis.append(s)
  else:
    s+=1
    lis.append(s)
print(max(lis))

Solution (Python):
N = int(input())
S = input()

X = [0]
for s in S:
    if s == 'I':
        X.append(X[-1]+1)
    else:
        X.append(X[-1]-1)

print(max(X))

Solution (Python):
n = int(input())
s = input()

x = nums =0
dic = {'I': 1, 'D': -1}
for i in s:
    x += dic[i]
    nums = max(x, nums)
print(nums)

Solution (Python):



def main():
    x = nums =0
    dic = {'I': 1, 'D': -1}
    for i in s:
        x += dic[i]
        nums = max(x, nums)
    print(nums)


if __name__ == '__main__':
    n = int(input())
    s = input()
    main()

Solution (Python):
x = 0
max_value = [0]

n = int(input())
s = input()

for j in s:
    if j == 'I':
        x += 1
        max_value.append(x)
    else:
        x -= 1
        max_value.append(x)
print(max(max_value))

Solution (Python):
x = 0
max_value = [0]

n = int(input())
s = input()

list = [i for i in s]

for j in list:
    if j == 'I':
        x += 1
        max_value.append(x)
    else:
        x -= 1
        max_value.append(x)
print(max(max_value))

Solution (Python):
N=int(input())
S=input()
history=[0]
for i in range(N):
  history.append(history[-1]+1) if S[i]=='I' else history.append(history[-1]-1)
print(max(history))

Solution (Python):
input()
g = m = 0
dic = {'I':1,'D':-1}
for s in input():
    g += dic[s]
    m = max(m,g)
print(m)

Solution (Python):
N = int(input())
S = list(input())
x = [0]
for i in range(N):
    if S[i] == 'I':
        x.append(x[i]+1)
    else:
        x.append(x[i]-1)
print(max(x))

Solution (Python):
n = int(input())
s = input()
listA=[0]
for i in range(n):
  if s[i]=="I":
    listA.append(listA[i]+1)
  elif s[i]=="D":
    listA.append(listA[i]-1)
listA.sort(reverse=True)
print(listA[0])

Solution (Python):
input();s=input()
m=0
c=0
for k in s:
  if k == 'I':
    c+=1
  else:
    c-=1
  if c >= m:
    m=c
print(m)

Solution (Python):
n=int(input())
s=input()
x,m=0,0
for i in range(n):
  if s[i]=='I':
    x+=1
  else:
    x-=1
  m=max(m,x)
print(m)

Solution (Python):
N = int(input())
S = input()

m = 0
x = 0

for c in S:
  if c=="I":
    x += 1
    m = max(m,x)
  elif c=="D":
    x -= 1
print(m)

Solution (Python):
N = int(input())
S = input()
x = 0
tmp = 0
for n in S:
    if n == 'I':
        tmp += 1
    elif n == 'D':
        tmp -= 1
    x = max(x, tmp)
print(x)

Solution (Python):
n = int(input())
s = input()
x = 0
ans = []
for i in s:
    if i == 'I':
        x += 1
    else:
        x -= 1
    ans.append(x)
ans = [0]+ans
print(max(ans))

Solution (Python):
N = int(input())
S = input()

xs = [0]
for s in S:
    if s == "I":
        xs.append(xs[-1] + 1)
    else:
        xs.append(xs[-1] - 1)
ans = max(xs)

print(ans)

Solution (Python):
n = int(input())
s = list(input())

x = [0 for _ in range(n + 1)]

for i in range(n):
    if s[i] == 'I':
        x[i+1] = x[i] + 1
    else:
        x[i+1] = x[i] - 1

print(max(x))

Solution (Python):
input();a=b=0
for x in input():b+=x>'D'or-1;a=max(a,b)
print(a)

Solution (Python):
from itertools import accumulate

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
S = input()[:-1]
l = [0]*(N+1)
for i, c in enumerate(S):
    if c == "I":
        l[i+1] += 1
    else:
        l[i+1] -= 1
l_acc = accumulate(l)
print(max(l_acc))

Solution (Python):
N = int(input())
S = input()
x = [0]*N

if S[0] == 'I':
        x[0] += 1
else:
    x[0] -= 1

for i in range(1,N):
    if S[i] == 'I':
        x[i] = x[i-1] + 1
    else:
        x[i] = x[i-1] - 1

print(max(x) if max(x) > 0 else 0)

Solution (Python):
n = int(input())
s = input()
x = [0]
num = 0
for i in range(n):
    if s[i]=='I':
        num += 1
        x.append(num)
    else:
        num -= 1
        x.append(num)
print(max(x))

Solution (Python):
N = int(input())
S = input()

m = 0
x = 0
for char in S:
    if char == 'I':
        x += 1
    else:
        x -= 1
    if x > m:
        m = x

print(m)

Solution (Python):
while True:
    try:
        n=int(input())
    except:
        break
    string=input()
    max=0
    x=0
    for i in string:
        if i=="D":
            x=x-1
        else:
            x=x+1
        if x>=max:
            max=x
    print(max)

Solution (Python):
n=int(input())
s=input()
ans=0
maxi=0
for i in range(n):
    if s[i]=="I":
        ans+=1
    elif s[i]=="D":
        ans-=1
    if ans>maxi:
        maxi=ans
print(maxi)

Solution (Python):
_ = int(input())
list_X = [0]
for i in list(input()):
    if(i == 'I'):
        list_X.append(list_X[-1]+1)
    else:
        list_X.append(list_X[-1]-1)
print(max(list_X))

Solution (Python):
n = int(input())
s = input()
ans = 0
now = 0

for i in range(n):
    if s[i] == 'I':
        now += 1
    else:
        now -= 1
    ans = max(ans, now)
print(ans)

Solution (Python):
N=int(input())
S=input()
x=0
ans=0
for i in S:
    if i=='I':
        x+=1
    else:
        x-=1
    ans = max(ans,x)
print(ans)

Solution (Python):
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("GREATER")
    elif (x<y): print("LESS")
    else: print("EQUAL")

def ip():
    return int(input())


def calculate(a):
    s = 0
    for i in range(len(a)):
        for k in range(i+1,len(a)):
            s+=(a[i]*a[k])
    return s

n = ip()                              




a = input()                                  






mx = 0
x = 0
for i in range(n):
    if a[i] == 'I':
        x+=1
        if mx < x:mx = x
    else: x-=1
print(mx)

Solution (Python):
n = int(input())
s_list = list(input())
x = 0
res = 0
for s in s_list:
    if s == 'I':
        x += 1
    elif s == 'D':
        x -= 1
    res = max(res,x)
print(res)

Solution (Python):
input();a=[0]
for x in input():a+=[a[-1]+((x>'D')or-1)]
print(max(a))

Solution (Python):
input();a=[0]
for x in input():a+=[a[-1]+((x>'D')or-1)]
print(max(a))

Solution (Python):
input();s=input();print(max(i-2*s[:i].count('D')for i in range(len(s)+1)))

Solution (Python):
n = int(input())
s = str(input())

x = 0
l = [0]*n

for i in range(n):
  if s[i] == 'I':
    x += 1
  elif s[i] == 'D':
    x -= 1
  l[i] = x

print(max(max(l), 0))

Solution (Python):
ans=0
now=0
n=int(input())
s=input()
for i in range(n):
    if s[i]=='I':now+=1
    elif s[i]=='D':now-=1
    ans=max(ans,now)
print(ans)

Solution (Python):
N = int(input())
S = list(input())
x = 0
max = 0

for i in range(N):
  if(S[i] == 'I'):
    x += 1
    if(max < x):
      max = x
  else:
    x -= 1
    if(max < x):
      max = x

print(max)

Solution (Python):
N = int(input())
S = input()
vals = [0]
for i in range(N):
    if S[i] == 'I':
        vals.append(vals[-1]+1)
    elif S[i] == 'D':
        vals.append(vals[-1]-1)
print(max(vals))

Solution (Python):
n = int(input())
s = input()

max_num=0
num = 0
for i in range(n):
  if s[i]=="I":
    num +=1
  elif s[i]=="D":
    num -=1
  max_num =max(num,max_num)
print(max_num)

Solution (Python):
n= int(input())
ss = input()
x = 0
ans = 0
for s in ss:
    x += 1 if s=='I'else -1
    ans = max(ans, x)
print(ans)

Solution (Python):

n = int(input())
S = input()
x = ans = 0
for s in S:
  if s == 'I':
    x += 1
    if x > ans:
      ans = x
  else:
    x -= 1
print(ans)

Solution (Python):
n=int(input());s=input();pd=0;ans=0
for i in range(0,n):
    if s[i]=='I':
        pd+=1
        if pd>ans:
            ans=pd
    else:
        pd-=1
print(ans)

Solution (Python):
n = int(input())
m = input()

x = 0
ans = 0

for i in range(n):
    if m[i] == 'I':
        x += 1
    else:
        x -= 1
        
    ans = max(x,ans)

print(ans)

Solution (Python):
N=int(input())
S=input()
x=0
s=0
for i in range(N):
  if S[i]=="I":
    x+=1
  else:
    x-=1
  s=max(s,x)
print(s)

Solution (Python):
n=int(input())
s=input()
max=0
sm=0
for i in range(n):
    if s[i]=='I':
        sm+=1
    else:
        sm-=1
    if max<sm:
        max=sm
print(max)

Solution (Python):
n=int(input())
s=list(input())
ans=0
tmp=0
for i in range(n):
    if s[i]=="I":
        tmp+=1
        ans=max(ans,tmp)
    else:
        tmp-=1
print(ans)

Solution (Python):
n = int(input())
s = input()
zz = 0
ex = [0]
for i in range(n):
	if s[i] == 'I':
		zz += 1
		ex.append(zz)
	else:
		zz -= 1
		ex.append(zz)
print(max(ex))

Solution (Python):
n=int(input())
s=input()

x=0
ans=0
for i in range(n):
  x=x+1 if s[i]=='I' else x-1
  ans=max(ans,x)
print(ans)

Solution (Python):
"""AtCoder"""

N = int(input())
S = input()

ans = 0
tmp = 0

for i in range(N):
  if S[i] == 'I':
    tmp += 1
  if S[i] == 'D':
    tmp -= 1
  if tmp > ans:
    ans = tmp

print(ans)

Solution (Python):
n = int(input())
s = input()
x = 0
xmax = 0
for c in s:
    if c == "I":
        x += 1
    if c == "D":
        x -= 1
    xmax = max(xmax, x)
print(xmax)

Solution (Python):
N = int(input())
S = input()

ans = 0
tmp = 0
for s in S:
  if(s == 'I'):
    tmp += 1
  else:
    tmp -= 1
  ans = max(ans, tmp)
print(ans)

Solution (Python):
n=int(input())
s=input()
x=0
m=0
for i in range(n):
    if s[i]=="I":
        x+=1
        if x>m:
            m=x
    else:
        x-=1
print(m)

Solution (Python):
n = int(input())
s = input()
x = [0]*(n+1)
for i in range(n):
    if s[i] == "I":
        x[i+1] = x[i]+1
    else:
        x[i+1] = x[i]-1
print(max(x))

Solution (Python):
n=int(input())
A=list(input())
t=0
ans=0
for i in A:
  if i=="D":
    t-=1
    ans=max(ans,t)
  else:
    t+=1
    ans=max (ans,t)
print(ans)

Solution (Python):



def main():
    n = int(input())
    s = input()
    val = 0
    ans = 0

    for si in s:
        if si == 'I':
            val += 1
        elif si == 'D':
            val -= 1

        ans = max(ans, val)

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
S = input()
tmp = 0
res = 0
for i in range(N):
  if S[i] == 'D':
    res -= 1
  else:
    res += 1
    
  if res > tmp:
    tmp = res
    
print(tmp)

Solution (Python):
n = int(input())
s = input()
ans = 0
tmp = 0
for c in s:
    if c == 'I':
        tmp += 1
    else:
        tmp -= 1
    ans = max(ans, tmp)
print(ans)

Solution (Python):
n = int(input())
s = input()
ans = 0
tmp = 0
for i in s:
    if i is 'I':
        tmp +=1
    else:
        tmp -= 1
    ans = max(ans, tmp)

print(ans)

Solution (Python):
N = int(input())
S = input()

x = 0
ans = 0

for i in range(len(S)):
    if S[i] == 'I':
        x += 1
    else:
        x -= 1
    ans = max(ans, x)

print(ans)

Solution (Python):
N = input()
S = raw_input()

x = 0
ans = 0
for s in S:
  if s=="I":
    x += 1
  else:
    x -= 1
  ans = max(ans, x)
print ans

Solution (Python):
n = int(input())
s = str(input())
l = []
c = 0
for i in range(len(s)):
    if s[i] == "I":
        c += 1
    elif s[i] == "D":
        c -= 1
    l.append(c)
print(max(max(l),0))

Solution (Python):
input()

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

Solution (Python):
n = int(input())
s = input()
ans = 0
x = 0
for i in range(n):
    if s[i] == "I":
        x += 1
    elif s[i] == "D":
        x -= 1

    if ans < x:
        ans = x

print(ans)

Solution (Python):
def fun():
     print(11)
     print(22)
     print(33)
     print(22)
N=eval(input())
S=input()
ls=[0]
x=0
for i in S:
     if i=='I':
          x+=1
          ls.append(x)
     else:
          x-=1
          ls.append(x)
result=max(ls)
print(result)

Solution (Python):
n = int(input())
s = input()

x=0
ans=x
for i in range(n):
    if s[i]=="I":
        x +=1
    else:
        x -=1
    if ans < x:
        ans = x

print(ans)

Solution (Python):
N = int(input())
S = input()
max = 0
x = 0
for i in S:
    if i == 'I':
        x += 1
    else:
        x -= 1
    if max < x:
        max = x

print(max)

Solution (Python):
N = int(input())
s = input()
X = [0]
x = 0
for n in range(N):
    if s[n] == 'I':
        x += 1
        X.append(x)
    else:
        x -= 1
        X.append(x)

print(max(X))

Solution (Python):
s=input()
t=[1 if i=="I" else -1 for i in list(input())]
ans,x=[0],0
for r in t:
  x+=r
  ans.append(x)
print(max(ans))

Solution (Python):
input()
x,mx=0,0
for c in input():
  x+=1 if c=="I" else -1
  mx=max(mx,x)
print(mx)

Solution (Python):
n=int(input())
s=input()
_max=0
tmp=0
for i in s:
    if i=='I':
        tmp += 1
        if tmp>_max:
            _max=tmp
    else:
        tmp -= 1
print(_max)

Solution (Python):
N = int(input())
S = input()

result = r = 0

for c in S:
    r += (c == "I") - (c == "D")
    result = max(result, r)

print(result)

Solution (Python):
n = int(input())
s = input()
max_n,g = 0,0
for i in s:
    g = g+1 if i=="I" else g-1
    max_n = max(max_n,g)
print(max_n)

Solution (Python):
n = int(input())
s = list(input())
max = 0
si = 0

for i in s:
    if i == "I":
        si += 1
    elif i == "D":
        si -= 1

    if si > max:
        max = si

print(max)

Solution (Python):
n = int(input())
s = input()
a = [0, 0]
for w in s:
    a[1] += 1 if w == 'I' else -1
    a[0] = max(a[0], a[1])
print(a[0])

Solution (Python):
N=int(input())
S=input()
LIST=[0]
x=0
for s in S:
    if s=="I":
        x+=1
    else:
        x-=1
    LIST.append(x)
print(max(LIST))

Solution (Python):
n = int(input())
S = input()
ans = 0
tmp = 0
for s in S:
    if s == 'I':
        tmp += 1
    else:
        tmp -= 1
    ans = max(ans, tmp)
print(ans)

Solution (Python):
N = int(input())
s = input()

res = 0
v = 0
for ss in s:
    if ss == 'I':
        v += 1
    else:
        v -= 1
    res = max(res, v)

print(res)

Solution (Python):
N = int(input())
S = input()
R = [None] * N

for i, s in enumerate(S):
    if i == 0:
        if s == 'I':
            R[i] =  1
        else:
            R[i] = -1
    else:
        if s == 'I':
            R[i] = R[i-1] + 1
        else:
            R[i] = R[i-1] - 1

print(max(0, max(R)))

Solution (Python):
N = int(input())
S = input()

num = [0]
n = 0
for s in S:
    if s == 'I': n += 1
    elif s == 'D': n -= 1
    num.append(n)

print(max(num))

Solution (Python):
N = int(input())
S = input()

x = 0
ans = 0
for c in S:
    x += 1 if c == 'I' else -1
    ans = max(ans, x)

print(ans)

Solution (Python):
n = int(input())
s = input()
x = 0
maxx = 0
for i in range(len(s)):
  if (s[i] == 'I'):
    x += 1
  else:
    x -= 1
  if (maxx < x):
    maxx = x
print(maxx)

Solution (Python):
n = int(input())
s = list(input())
maxx = 0
x = 0
for i in range(n):
    if s[i]=='I':
        x+=1
    elif s[i]=='D':
        x-=1
    maxx = max(maxx,x)
print(maxx)

Solution (Python):
n = int(input())
s = input()

x = 0
ans = 0
for i in range(n):
	if s[i] == 'I':
		x += 1
		ans = max(x, ans)
	elif s[i] == 'D':
		x -= 1
		ans = max(x, ans)

print(ans)

Solution (Python):
n = int(input())
s = input()
x = 0
ans =  0
for i in (s):
  if i == 'I':
    x += 1
  else:
    x -= 1
  
  ans = max(ans,x)

print(ans)

Solution (Python):
n = input()
n = int(n)
str = input()
val = [0]
x = 0
for _ in range(n):
  o = str[:1]
  if o == 'D':
    x -= 1
  else:
    x += 1
  val.append(x)
  str = str[1:]
print(max(val))