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())
A = [0]

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

print(max(A))

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

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

slist = [0]
sval = 0
for i in s :
    if i == "I":
        sval += 1
        slist.append(sval)
    else:
        sval -= 1
        slist.append(sval)
print(max(slist))

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

x = 0
temp = 0
for n in range(N):
    if S[n]=='I':
        temp+=1
    elif S[n]=='D':
        temp-=1
    if temp > x:
        x = temp
print(x)

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

Solution (Python):
def INT():
    return int(input())

def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

N = INT()
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=input();s=input();
x=0
max_num=0
for i in s:
  if i=='I':
    x+=1
  else:
    x-=1
  max_num=max(max_num,x)
print(max_num)

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

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

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

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

x = 0
max = 0

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

Solution (Python):
import sys
N = int(input())
S = str(input())
if N <= 0 or N > 100:
    sys.exit()
x = 0
max = 0
for I in S:
    if I == "I":
        x += 1
        if max < x:
            max = x
        continue
    if I == "D":
        x -=1
        continue
print(max)

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()
t=0
m=0
for x in s:
    if x=='I': t+=1
    else: t-=1
    m = max(m, t)
print(max(m, 0))

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

Solution (Python):
N = int(input())
S = input()
x = 0
ans = [x]
lis_S = list(S)

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

    ans.append(x)

print(max(ans))

Solution (Python):


import sys
input=sys.stdin.readline

def main():
    N=int(input())
    S=input()
    maxx=0
    for i in range(1,N+1):
        maxx=max(maxx,S[:i].count("I")-S[:i].count("D"))
    print(maxx)
    
if __name__=="__main__":
    main()

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

dp = [0 for j in range(len(S)+1)]

for i in range(len(S)):
    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]
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()
x = 0
xmax = 0
for i in range(N):
    if S[i] == "I":
        x += 1
    elif S[i] == "D":
        x -= 1
    if xmax <= x:
        xmax = x
print(xmax)

Solution (Python):
"""
N = list(map(int,input().split()))
S = [str(input()) for _ in range(N)]
S = [list(map(int,list(input()))) for _ in range(h)] 
print(*S,sep="")
"""

import sys
sys.setrecursionlimit(10**6)
input = lambda: sys.stdin.readline().rstrip()
inf = float("inf") 

n = int(input())
s = input()
count = 0
max_num = 0
for _ in s:
    if _=="I":
        count+=1
    else:
        count-=1
    if max_num<count:
        max_num=count
print(max_num)

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

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

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

Solution (Python):




input()
s = input()

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

print(ans)

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

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

cnt=0
maxcnt=0

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

Solution (Python):
_ = input()
s = input()
ans = 0
c = 0
for i in s:
    c += 1 if i == "I" else -1
    ans = max(ans, c)
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(x, ans)

print(ans)

Solution (Python):
n = int(input())
s =input()
x = 0
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):
def resolve():
    N = int(input())
    S = input()
    am = [0]
    ans = 0
    for i in range(N):
        if S[i] == "I":
            ans += 1
        if S[i] == "D":
            ans -= 1
        am.append(ans)
    print(max(am))
resolve()

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

cnt = 0
res = 0
for i in range(N):
    if S[i] == 'I':
        cnt +=1
    else:
        cnt -=1
    if cnt > res:
        res = cnt
print(res)

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

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

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

print(res)

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

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

Solution (Python):
def maximumx(N, S) : 
  x = 0
  max = 0
  
  for i in range(N) : 
    if S[i] == 'I' : 
      x += 1
      if max < x :
        max = x
    else : 
      x -= 1 
      
  return max


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

print(maximumx(N, S))

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())
x=0
ans=0
s=input()
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()
x = 0
maxi = 0
for char in S:
    if char == "I":
        x += 1
        maxi = max(maxi, x)
    else:
        x -= 1
print(maxi)

Solution (Python):

import sys
from collections import defaultdict, deque




def solve():
    n = int(input())
    s = input()
    cnt = 0
    ans = 0
    for e in s:
        if e == 'I':
            cnt += 1
        else:
            cnt -= 1
        ans = max(ans, cnt)
    print(ans)
        
t = 1

for case in range(1,t+1):
    ans = solve()



"""

1 4
7
RRRR
1 1 0 1
----
4

1 4
47
RCRR
1 1 0 1
----
-1

2 2
10
RR
RR
1 7
4 1
----
4

2 2
10
RR
RR
7 4
7 4
----
-1

3 3
8
RCR
RRC
RRR
1 1 1
1 1 1
1 3 1


3 3
1
RCR
RRC
RRR
1 1 1
1 1 1
1 3 1


"""

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

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

print(max_x)

Solution (Python):
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

n = i()
s = s()
cnt = 0
ans = 0

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

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

ans = []
for i in range(0,N):
  if S[i] == "I":
    cnt = cnt+1
  elif S[i] == "D":
    cnt = cnt-1
  ans.append(cnt)

if max(ans) <= 0:
  print("0")
else:
  print(max(ans))

Solution (Python):
import math
from collections import deque
from collections import defaultdict

import bisect



def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): 
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): 
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} 
def bitArr(n):
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): 
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq

n = readInt()
s = readChar()

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()

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

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

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

print(max(a))

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(map(str,input()))
ans = []
ans.append(0)
tmp = 0

for i in s:
    if i == "I":
        tmp += 1
        ans.append(tmp)
    else:
        tmp -= 1
        ans.append(tmp)
        
print(max(ans))

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

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

Solution (Python):
n=int(input())
s=list(input())
max=0
x=0
for c in s:
  if c=="D":
    x-=1
  else :
    x+=1
    if max<x:
      max=x
      
print(max)

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 max_num < x:
        max_num = x
print(max_num)

Solution (Python):
n = int(input())
S = input()
Ans = [0]
ans = 0
for s in S:    
    if s == "I":
        ans += 1
    else:
        ans -= 1
    Ans.append(ans)

print(max(Ans))

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


def read():
    N = int(input().strip())
    S = input().strip()
    return N, S


def solve(N, S):
    x = 0
    xmax = 0
    for s in S:
        if s == "I":
            x += 1
            xmax = max(xmax, x)
        else:
             x -= 1
    return xmax


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))

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

Solution (Python):
n = int(input())
s = input()
x = 0
arr = [0]
d = {'I': 1, 'D': -1}
for i in range(n):
  x += d[s[i]]
  arr.append(x)
print(max(arr))

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

x = 0
ans = 0

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

    ans = max(ans, x)

print(ans)

Solution (Python):
n = int(input())
S = list(input())
A = [0]
loop = 0
for e in S:
    A.append(A[loop] + 1) if e == 'I' else A.append(A[loop] - 1)
    loop += 1
print(max(A))

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

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

count = [0]
c = 0
for i in l:
    if i == 'I':
        c += 1
        count.append(c)
    elif i == 'D':
        c -= 1
        count.append(c)
print(max(count))

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

print(ans)

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

print(max(ans))

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

Solution (Python):
n = int(input())
S = input()
A = []
cur = 0
for i in S:
    if i == 'I':
        cur += 1
    else:
        cur -= 1
    A.append(cur)
    
print(max(max(A), 0))

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

d = S.count('D')
i = S.count('I')
cnt = 0
cntold = 0
for n in range(N):
    if S[n] == 'D':
        cnt -= 1
    else:
        cnt += 1
    
    if cnt > cntold:
        cntold = cnt
print(cntold)

Solution (Python):

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

result = [0]
cnt = 0
for i in range(n):
    if s[i] == 'I':
        cnt += 1
        result.append(cnt)
    else:
        cnt -= 1
        result.append(cnt)
        
print(max(result))

Solution (Python):
N=int(input())
S=list(str(input()))
x=0
x_max=0
for i in S:
  if i=='I':
    x+=1
    if x>x_max:
      x_max=x
  else:
    x-=1
print(x_max)

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

ans = 0
x = 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()
x=0
ans=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):
N = int(input())
S = list(input())
A = [0]
ans = 0
for s in S:
    if s == 'I':
        ans += 1
    else:
        ans -= 1
    A.append(ans)
print(max(A))

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):
if __name__ == '__main__':
    a = int(input())
    s = input()
    count =0
    max = 0
    for i in s:
        if i == "I":
            count +=1
        else:
            count -=1

        if max < count:
            max = count
    print(max)

Solution (Python):

import sys


def solve(N: int, S: str):
    ids = [0] * (N + 1)
    for i, s in enumerate(S):
        p = -1 if s == "D" else 1
        ids[i + 1] += ids[i] + p
    print(max(ids))
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    N = int(next(tokens))  
    S = next(tokens)  
    solve(N, S)


if __name__ == "__main__":
    main()

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

res = 0
x = 0

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

print(res)

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):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
from fractions import gcd
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

from itertools import permutations
from math import factorial, hypot





N = getN()
now = 0
ans = 0
S = input()

for st in S:
    if st == "I":
        now += 1
    else:
        now -= 1
    ans = max(ans, now)
print(ans)

Solution (Python):
def li():
    return list(map(int, input().split()))
def mi():
    return map(int, input().split())
def ii():
    return int(input())

N = ii()
S = input()

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

print(maxx)

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
mx = 0
for s in S:
    x += 1 if s == "I" else -1
    mx = max(x, mx)
print(mx)

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

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

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

print(max(A))

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

count = 0
result = 0
for i in S:
  if i == "I":
    count += 1
  else:
    count += -1
  result = max(count,result)
print(result)

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

max_value = 0
value = 0
for c in S:
    if c == 'I':
        value += 1
    elif c == 'D':
        value -= 1
    max_value = max(value, max_value)
print(max_value)

Solution (Python):
n = int(input())
s = input()
c = 0
maxc = 0
for i in s:
    if i == 'I':
        c += 1
    else:
        c -= 1
    if maxc < c:
        maxc = c
print(maxc)

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):
a = [input() for i in range(2)]
result = int(0)
maxAns = int(0)
for c in a[1]:
    if c == 'I':
        result += 1
    elif c == 'D':
        result -= 1
    
    if result > maxAns:
        maxAns = result

print(maxAns)

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
  ans.append(x)
print(max(ans))

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

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

Solution (Python):
n=int(input())
s = input()
ls = len(s)
ans = 0
for i in range(1,ls+1):
    ans = max(ans, s[:i].count('I')-s[:i].count('D'))
print(ans)

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

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

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

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

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

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

print(max_x)

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

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

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

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

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):
def ABC_52_B():
    N = int(input())
    S = input()
    xl=[]
    x=0

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

        xl.append(x)
    
    if max(xl)>=0:
        print(max(xl))
    else:
        print(0)

if __name__ == '__main__':

    ABC_52_B()

Solution (Python):

import sys
input = sys.stdin.readline









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

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

res = 0
x = 0
for i, v in enumerate(s):
    if v == 'I':
        x += 1
    else:
        x -= 1
    res = max(res, x)
print(res)

Solution (Python):
from sys import stdin
def S(): return stdin.readline().rstrip()
def I(): return int(stdin.readline().rstrip())

n = I()
s = S()

ans = 0
x = 0

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

print(ans)

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 m < x:
        m = x

print(m)

Solution (Python):
n = int(input())
s = input()
x = 0
j = 0
for i in range(len(s)):
  j = j + (s[i]=='I') - (s[i]=='D')
  x = max(x,j)
print(x)

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

Solution (Python):
def main():
    N = int(input())
    S = list(input())
    cnt = 0; ans = 0
    for s in S:
        cnt += (s == 'I') - (s == 'D')
        ans = max(cnt, ans)
    print(ans)

if __name__ == "__main__":
    main()

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

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

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())
S = input()
ans = 0
x = 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()
x=0
ans=0
for i in S:
    if i=='I':
        x+=1
    else:
        x+=-1
    if ans<x:
        ans=x
print(ans)

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

print(ans)

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

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

Solution (Python):

N = int(input())



S= str(input())
x=0
max=0
for i in S:
    if i == 'I':
        x+=1
        if x>=max:
            max=x
    elif i== 'D':
        x-=1

print(max)

Solution (Python):


import sys






























def main():
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n = ii()
    s = input()
    x = 0
    max_memo = 0
    for char in s:
        if char == 'I':
            x += 1
            max_memo = max(x, max_memo)
        else:
            x -= 1
    print(max_memo)


if __name__ == "__main__":
    main()

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

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

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

Solution (Python):
n = int(input())
s = input()
a = []
a.append(0)

for i in range(n):
    if s[i] == 'I':
        a.append(a[i]+1)
    else:
        a.append(a[i]-1)
print(max(a))

Solution (Python):
n = int(input())
s = input()
a = []
a.append(0)

for i in range(n):
    if s[i] == 'I':
        a.append(a[i]+1)
    else:
        a.append(a[i]-1)
print(max(a))

Solution (Python):
n = int(input())
s = input()
a = []
a.append(0)

for i in range(n):
    if s[i] == 'I':
        a.append(a[i]+1)
    else:
        a.append(a[i]-1)
print(max(a))

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

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

Solution (Python):
n = int(input())
s = input()
a = []
a.append(0)

for i in range(n):
    if s[i] == 'I':
        a.append(a[i]+1)
    else:
        a.append(a[i]-1)
print(max(a))

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())
s = input()

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

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

a = [0]*N

x = 0

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