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=str(input())
x=0
x_max=0

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

print(x_max)

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

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

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

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

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

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

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

Solution (Python):

N = int(input())
S = input()
n = 0
M = 0
for i in range(N):
    if S[i] == "I":
        n = n + 1
        if n >= M:
            M = n
    else:
        n = n - 1
print(M)

Solution (Python):
from itertools import accumulate

input()
print(max([0] + list(accumulate([1 if s=='I' else -1 for s in input()]))))

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

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

c=0
m=0
for i in s:
    if(i=='I'):
        c+=1
    else:
        c-=1
    if(m<c):
        m=c
print(m)

Solution (Python):
n=int(input())
a=input()
cnt=0
ans=0
for i in a:
    if i=="I":
        cnt+=1
    else:
        cnt-=1
    ans=max(ans,cnt)
print(ans)

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

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

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())
t=list(input())
x=0
ans=0
for i in range(n):
    if t[i]=='I':
        x+=1
    else:
        x-=1
    if ans<x:
        ans=x
print(ans)

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

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

Solution (Python):

import sys
input = sys.stdin.readline


N = int(input())
S = input().rstrip()

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

print(ans)

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

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

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

print(ans)

Solution (Python):
def examB():
    N = I()
    St = S()
    cur = int(0)
    ans = int(0)
    for s in St:
        if s=="I":
            cur +=1
        elif s=="D":
            cur -=1
        ans = max(ans,cur)
    print(ans)

import sys
import copy
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

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

Solution (Python):
N = int(input())
S = str(input())
x = 0
m = 0
for i in range(N):
  if S[i]=='I':
    x += 1
  elif S[i]=='D':
    x -= 1
  m = max(m,x)
print(m)

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

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())
x=0
data=[]
for i in range(N):
    if S[i]=="I":
        x=x+1
    else:
        x=x-1
    data.append(x)
print(max(0,max(data)))

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

Solution (Python):

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

x = 0
max_value = 0

for c in s:
    if c == 'I':
        x += 1
        max_value = max(max_value, x)
    elif c == 'D':
        x -= 1
    
print(max_value)

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

def main():
    n = inp()
    s = input()
    x = 0
    res = 0
    for i,j in enumerate(s):
        if j == 'I':
            x += 1
        else:
            x -= 1
        res = max(res, x)
    print(res)
if __name__ == '__main__':
    main()

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

print(max_num)

Solution (Python):
from collections import deque

N = int(input())
S = deque(list(input()))

def main():
    ans = 0
    curr = 0
    while S:
        s = S.popleft()
        curr += 1 if s == 'I' else -1
        ans = max(ans, curr)
    print(ans)

if __name__ == '__main__':
    main()

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

Solution (Python):



N, S = [s for s in open(0)]

list_S = [1 if i == 'I' else -1 for i in list(S)]


add_list = 0
ans = 0
for j in list_S:
    add_list += j
    ans = max(add_list,ans)

print(ans)

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

Solution (Python):
A = int(input())
S = input()
s = 0
count = 0
for i in S:
  if (s<=count)and(i == 'I'):
    count += 1
    s = count
  elif i == 'I':
    count += 1
  else:
    count += -1
print(s)

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

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

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

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

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

x = 0
x_list = [x]
for si in input():
  if si == 'I':
    x = x + 1
  if si == 'D':
    x = x - 1
  x_list.append(x)

print(max(x_list))

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

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

print(ans)

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

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

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

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

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

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

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

Solution (Python):

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

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

count = 0
count_list = [0]
for i in S:
    if i == 'I':
        count += 1
        count_list.append(count)
    elif i == 'D':
        count -= 1
    else:
        print('Error')
    
print(max(count_list))

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

for char in S:
    if char == 'I':
        x += 1
        max_of_x = max(max_of_x, x)
    else:
        x -= 1

print(max_of_x)

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

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

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

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().strip()
cmax = 0
cnt = 0
for i in range(N):
    if S[i]=="I":
        cnt += 1
    else:
        cnt -= 1
    cmax = max(cmax,cnt)
print(cmax)

Solution (Python):
n = int(input())
s = list(input())
ans = [0 for i in range(n + 1)]

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

print(max(ans))

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

Solution (Python):
_ = input()
a = [0]
b = 0
S = list(input())
for i in S:
    if i == "I":
        b += 1
    else:
        b -= 1
    a.append(b)
print(max(a))

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

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

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
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()
ans,cnt=0,0
for i in range(n):
    if s[i]=='I':
        cnt+=1
    else:
        cnt-=1
    ans=max(ans,cnt)
print(ans)

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

print(int(max))

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

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

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

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

Solution (Python):



n = int(input())
l = list(input())
cnt=0
ans=0

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

print(ans)

Solution (Python):
_ = input()
S = input()
max_n = 0
temp = 0

for s in S:
  if s == 'I':
    temp += 1 
  else:
    temp -= 1
  
  if max_n < temp:
    max_n = temp
    
print(max_n)

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

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

maxi=0 
x=0 
for i in s: 
    if i=='D':
        x-=1 
    else: 
        x+=1 
    maxi=max(maxi,x)
print(maxi)

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

count = 0
ans = 0
for x in s:
    if x == 'I':
        count += 1
    elif x == 'D':
        count -= 1
    ans = max(count, ans)
print(ans)

Solution (Python):
import collections
import itertools
import functools
import math

if __name__ == "__main__":
    x = 0
    m = 0
    input()  
    s = input()
    for letter in s:
        if letter == "I":
            x += 1
        elif letter == "D":
            x -= 1
        m = max(m, x)
    print(m)

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

Solution (Python):

N = int(input())
S = input()
L = []

t = 0
ans = 0

for s in S:
    if s == 'I':
        t += 1
        ans = max(ans,t)
        L.append(ans)
        continue

    if s == 'D':
        t -= 1
        ans = max(ans,t)
        L.append(ans)
        continue

print(max(L))

Solution (Python):
N = int(input())
S = input()
X = [0]
x = 0
for s in S:
  if s == 'I':
    x += 1
    X.append(x)
  else:
    x -= 1
    X.append(x)
X.sort(reverse = True)
print(X[0])

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

Solution (Python):
from sys import exit, stdin
N = int(stdin.readline().rstrip())
S = stdin.readline().rstrip()
xs = [0]
x = 0
for s in S:
    if s == 'I':
        x += 1
    elif s == 'D':
        x -= 1
    xs.append(x)
print(sorted(xs)[-1])

Solution (Python):
n=int(input())
s=input()
ans=0
x=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 = list(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())
string=input()
x=[0]*(N+1)
cnt=0
for idx,s in enumerate(string):
  if s=='I':
    cnt+=1
    x[idx]=cnt
  else:
    cnt-=1
    x[idx] = cnt
print(max(x))

Solution (Python):
def resolve():
    n=int(input())
    s=input()
    mx,x=0,0
    for i in s:
        if i=='I':
            x+=1
        elif i=='D':
            x-=1
        mx=max(x,mx)
    print(mx)
resolve()

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

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

print(ans)

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

Solution (Python):
input()
S = input()
mcnt = 0
crr = 0
for s in S:
    if s == "I":crr += 1
    else:crr -= 1
    mcnt = max(mcnt,crr)
print(mcnt)

Solution (Python):
x_list = []

n = int(input())
s = str(input())
x = 0
x_list.append(x)

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

print(max(x_list))

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

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

print(ans)

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

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

max_n = 0
n = 0
for s in S:
  if s == "I":
    n += 1
    if n > max_n:
      max_n = n
  else:
    n -= 1

print(max_n)

Solution (Python):
N = int(input())
D = input()
x = 0
mx = 0
for i in D:
  if i == "I":
    x += 1
    if mx < x:
      mx = x
  elif i == "D":
    x -= 1
print(mx)

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

x = 0
ans = 0

for i in range(N):
    if S[i] == "I":
        x += 1

    elif S[i] == "D":
        x -= 1

    ans = max(ans, x)

print(ans)

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

Solution (Python):
_ = input()

curr = 0
ans = curr
for a in input():
    if a == 'I':
        curr += 1
        ans = max(ans, curr)
    else:
        curr -= 1

print(ans)

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

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    s = str(input().rstrip('\n'))
    t = 0
    mt = 0
    for i in range(n):
        if s[i] == "I":
            t += 1
        else:
            t -= 1
        mt = max(mt, t)
    print(mt)


if __name__ == '__main__':
    slove()

Solution (Python):
n=int(input())
s=input()
now=0
ans=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()
l=[0]
c=0
for i in range(n):
    if s[i]=='I':
        c+=1
        l.append(c)
    else:
        c-=1
        l.append(c)
print(max(l))

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

Solution (Python):
x = 0
n = int(input())
s = list(input())
m = 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()
x = 0
res = 0
for i in range(N):
    if S[i] == 'I':
        x += 1
    else:
        x -= 1
    if res < x:
        res = x
print(res)

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

now=0
ans=0

for n in range(N):
  if S[n]=='I':
    now+=1
  else:
    now-=1
  
  if now>ans:
    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):
n=int(input())
s=input()
ans = 0
x = 0
for i in s:
  if i=="I":
    x+=1
  else:
    x-=1
  ans = max(ans,x)
print(ans)

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

Solution (Python):
input()
x = res = 0

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

print(res)

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

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

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

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

count = 0
ans = 0

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

print(ans)

Solution (Python):
n= int(input())
s= list(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()
ans = 0
tmp = 0
for i in s:
    if i == "I":
        tmp += 1
    else:
        tmp -= 1
    ans = max(ans, tmp)
print(ans)

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

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

ans = 0
ls = [0]

for i in s:
    if i == 'I':
        ans += 1
    else:
        ans -= 1
    ls.append(ans)

print(max(ls))

Solution (Python):
n = input()

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

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

Solution (Python):
n = int(input())
s = input()
x = ans = 0
for c in s:
    x += [-1, 1][c == 'I']
    ans += (ans < x)+0
print(ans)

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

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


count = 0
Max = 0

for s in S:
    if s == 'I':
        count += 1
        if Max < count:
            Max = count
    elif s == 'D':
        count -= 1

print(Max)

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

if __name__ == "__main__":
    incre()

Solution (Python):
n = int(input())
s = input()
x = 0
m = [0,]

for i in range(len(s)):
    if s[i] == 'I':
        x += 1
        m.append(x)
    elif s[i] == 'D':
        x -= 1
        m.append(x)
else:
    print(max(m))

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=int(input())
s=list(input())
x=0
ans=0
for i in range(n):
    if s[i]=="I":
        x+=1
        ans=max(ans,x)
    else:
        x-=1
        ans=max(ans,x)
print(ans)

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

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

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

Solution (Python):
def resolve():
    n = int(input())
    s = input()
    x = 0
    ans = 0
    for c in s:
        x += 1 if c == "I" else -1
        if x > ans:
            ans = x
    print(ans)


if __name__ == "__main__":
    resolve()

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

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

Solution (Python):
n,s=open(0);print(max(i-s[:i].count("D")*2for i in range(int(n)+1)))

Solution (Python):
n,s=open(0);print(max(s[:i].count("I")*2-i for i in range(int(n)+1)))

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

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

print (ans)

Solution (Python):

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

Solution (Python):
N = int(input())
S = input()
res = [0] + [0] * len(S)

for i,s in enumerate(S, 1):
    if s == "I":
        res[i] = res[i-1] + 1
    else:
        res[i] = res[i-1] - 1

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

Solution (Python):
import sys
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
s = S()
N = len(s)

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()
x = 0
max_x = 0

for i in range(n):
  if s[i] == "I":
    x += 1
  else:
    x -= 1
  if x > max_x:
    max_x = x
print(max_x)

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

Solution (Python):


s = [input() for i in range(2)]

N = int(s[0])
S = str(s[1])
x = 0
y = [x]

for j in range(N):
    if  S[j] == "I":
        x = x + 1
        y.append(x)
    else:
        x = x - 1
        y.append(x)

print(max(y))

Solution (Python):
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    s = input().strip()

    ans = 0
    tmp = 0
    for i in range(N):
        if s[i] == "I":
            ans += 1
        else:
            ans -= 1
        tmp = max(tmp, ans)
    print(tmp)


if __name__ == "__main__":
    main()

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

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

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(x,ans)
print(ans)

Solution (Python):


n = int(input())
s = input()
x = 0

ans = 0
for let in s:
    if let == "I":
        x += 1
    else:
        x -= 1

    ans = max(ans, x)

print(ans)

Solution (Python):
N=int(input());S=input();print(max(S[:i].count("I")-S[:i].count("D")for i in range(N+1)))

Solution (Python):
input()
s = input()
count,max_ = 0,0
for i in range(len(s)
):
    if s[i] == "I":
        count += 1
        max_ = max(count,max_)
    else:
        count -= 1
        max_ = max(count,max_)

print(max_)

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




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

print(max(x_list))

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

ans = 0
x = 0
for v in s:
    if v == 'I':
       x += 1
       ans = max(ans, x)
    elif v == 'D':
        x -= 1

print(ans)

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

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

Solution (Python):

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

a ,ans_a=0,0

for i in range(n):
  if s[i] =='I':
    a +=1
    if ans_a <a:
      ans_a = a
  elif s[i] =='D':
      a -=1
print(ans_a)

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

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

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

Solution (Python):
from itertools import accumulate
N = int(input())
S = input()
a = [1 if s == "I" else -1 for s in S]
X = [0] + list(accumulate(a))
print(max(X))

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

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

ans=0
x=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()
ans = []
x = 0
for i in range(N):
  x = x+1 if S[i] == 'I' else x-1
  ans.append(x)
print(max(max(ans),0))

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()
print(max([s[:i].count('I')-s[:i].count('D') for i in range(n+1)]))

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

s = list(S)

count = 0
max = 0

for i in range(N):
    if s[i] == 'I':
        count += 1
        if count > max:
            max = count
    else:
        count += -1

print(max)

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

Solution (Python):
import numpy as np

N = int(input())
S = input()
L = np.array([0] + [1 if x == 'I' else -1 for x in S])
L_cum = L.cumsum()

print(max(L_cum))

Solution (Python):
N = int(input())
S = input().split()
X = 0

S1 = list(S[0])


S1_mod = [1 if i == "I" else i for i in S1]
S1_mod = [-1 if i == "D" else i for i in S1_mod]

l = []
for i in S1_mod:
  if i == -1:
    X += -1
    l.append(X)
  else:
    X+= 1
    l.append(X)


if max(l) < 0:
  print(0)
else:
  print(max(l))

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

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

Solution (Python):
input()
s=input()
c,m=0,0
for i in range(len(s)):
    if s[i]=="I":
        c+=1
        m=max(c,m)
    if s[i]=="D":
        c=c-1
        m=max(c,m)
print(m)

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