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):
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-=1
    m=max(c,m)
print(m)

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

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
S = input()

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

print(ans)

Solution (Python):

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

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

Solution (Python):


n = int(input())
s = input()
x = 0 
xs = [x] 

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

print(max(xs))

Solution (Python):
"""
author : halo2halo
date : 31, Jan, 2020
"""

import sys
import itertools



read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())
S = readline().decode('utf8')

ans = 0
cnt=0
for i in S:
    
    if i == 'I':
        cnt += 1
    else:
        cnt -= 1

    ans=max(ans, cnt)
print(ans)

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

x_temp = 0
x_max = 0

for si in s:
    if si == 'I':
        x_temp += 1
    elif si == 'D':
        x_temp -= 1
    x_max = max(x_max, x_temp)
    
print(x_max)

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

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

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

print(ans)

Solution (Python):
input()
apply_nums = [1 if x == 'I' else -1 for x in list(input())]

num = 0
_max = num
for apply_num in apply_nums:
    num += apply_num
    _max = max(num, _max)
print(_max)

Solution (Python):
N = int(input())
S = 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()
total=[0]
num=0
for s in S:
    if s=="I":
        num+=1
    else:
        num-=1
    total.append(num)
print(max(total))

Solution (Python):
input()
c=0
yy=0
b=list(input())
for i in b:
    if i == "I":
        c=c+1
    if i == "D":
        c=c-1
    if c > yy:
        yy=c
print(yy)

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

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

print(max(ans))

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

ans = 0
wrk = 0
for i in s:
    if i == 'I':
        wrk +=1
    if i == 'D':
        wrk -=1

    ans = max(ans,wrk)
print(ans)

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

for i in range(N):
    a = S[i]
    if a == "I":
        x = x + 1
    else:
        x = x - 1
    if num < x:
        num = x
        
print(num)

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

x = 0
max_x = 0

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

    if x > max_x:
        max_x = x

print(max_x)

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

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

Solution (Python):

import sys
INF = float("inf")


def solve(N: int, S: str):

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

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

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

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n = INT()
    s = input()
    l = [0] * (n + 1)

    for i in range(n):
        if s[i] == "I":
            l[i] = l[i-1] + 1
        else:
            l[i] = l[i-1] - 1
    print(max(l))
if __name__ == "__main__":
    main()

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


def main():
    n = int(input())
    s = input()
    ans = -1000
    x = 0
    for st in s:
        if st == 'I':
            x+=1
        else:
            x-=1
        ans = max(ans, x)
    if ans>=0:
        print(ans)
    else:
        print(0)
main()

Solution (Python):
N = int(input())
S = input()
m = 0
p = 0
for i in S:
  if i == "D":
    p -= 1
  else:
    p += 1
  if p >= m:
    m = p
print(m)

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

x = 0

out =  [0]

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

print(max(out))

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

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

for ss in s:
  if ss == "I":
    x+=1
  elif ss == "D":
    x-=1
  
  if x > max:
    max = x
    
print(max)

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

Solution (Python):
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    ans=0
    temp=0
    n=INT()
    s=STR()
    for i in s:
        if i=='I':
            temp+=1
            ans=max(ans,temp)
        else:
            temp-=1
    print(ans)
if __name__ == '__main__':
    do()

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

x = 0
plus_number = [0]
for i in range(len(S)):
  if S[i] == "I":
    x += 1
  elif S[i] == "D":
    x -= 1
  plus_number.append(x)
print(max(plus_number))

Solution (Python):
n = [input() for _ in range(2)]
ans = 0
a = []

for i in range(int(n[0])):

	if n[1][i] == "I":
		ans = ans + 1
		a.append(ans)
	elif n[1][i] == "D":
		ans = ans - 1
		a.append(ans)

print(max(0,max(a)))

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

    

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

    return ans


if __name__ == '__main__':
    res = solve()
    print(res)

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

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

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

Solution (Python):


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

slist = list(s)
x = 0
xmax = 0

for i in slist:
  if i == "I":
    x = x + 1
  else:
    x = x - 1
  
  if x > xmax:
     xmax = x

print(xmax)

Solution (Python):
import sys
input = sys.stdin.readline
n=int(input())
s=input().strip()
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
for i in range(1, N+1):
    x = max(x, S[:i].count('I') - S[:i].count('D'))
print(x)

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

x=0
max_x=0

for si in list(s):
    if(si=="I"):
        x+=1
    else:
        x-=1
    if(max_x<x):
        max_x=x
print(max_x)

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

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

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

count = 0
cmax = 0
for i in s:
  if i == 'I':
    count += 1
  else:
    count -= 1

  if count > cmax:
    cmax = count

print(cmax)

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

ans = 0
tmp = 0
for char in string:
	if char == "I":
		tmp += 1
	else:
		tmp -= 1
	ans = max(ans, tmp)
print(ans)

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

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

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

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

Solution (Python):


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

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

print(max(lis))

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

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

Solution (Python):

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

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

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

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

print(ans)

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

print(max_x)

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

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

m,c=0, 0
for i in s:
    if i=="I":
        c+=1
        m=max(m,c)
    if i=="D":
        c-=1
        m=max(m,c)
        
print(m)

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

Solution (Python):
N = int(input())
s = input()
length = len(s)
tmp = 0
ans = 0
for i in range(length):
    if s[i] == 'I':
       tmp += 1
       if tmp > ans:
           ans = tmp

    else:
        tmp -= 1

print(ans)

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

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

print(max_ans)

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

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

Solution (Python):
N = int(input())
res = [0]
x = 0
for s in input():
  if s == 'I':
    x += 1
  elif s =='D':
    x -= 1
  res.append(x)

print(max(res))

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

print(Max)

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


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


print(max)

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

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

Solution (Python):
N = int(input())
S = input()
dp = [0]*(N+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):

 
import math
import itertools
import sys
import copy
 


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

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

print (m)

Solution (Python):
n = input()
S = input()
A = [1 if s == "I" else -1 for s in S]
cum_A = [0]*(len(A)+1)
for i in range(len(A)):
  cum_A[i+1] += A[i] + cum_A[i]

print(max(cum_A))

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

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

print(maxi)

Solution (Python):
N = int(input())
S = list(map(lambda x:1 if x=='I' else -1, input()))
x = 0
max_x = 0

for s in S:
	x += s
	max_x = max(max_x, x)
print(max_x)

Solution (Python):
N=int(input())
S=input()
cnt=0
ans=0
for s in S:
    if s=="I":
        cnt+=1
        ans=max(ans,cnt)
    if s=="D":
        cnt-=1
print(max(0,ans))

Solution (Python):
import copy
n = int(input())
s = list(input())
ans = 0
x = 0
for i in s:
    if i == "I":
        ans = ans + 1
        if ans > x:
            x = copy.copy(ans)
    else:
        ans = ans - 1
print(x)

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

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

Solution (Python):

_ = input()


S = input()


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

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

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

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

ans = 0
tmp = 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 = list(input())

ans = 0
l = [0]

for i in range(n):
    if s[i] == "I":
        ans += 1
        l.append(ans)
    elif s[i] == "D":
        ans -= 1
        l.append(ans)

print(max(l))

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

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

x = 0
ans = []  

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

if max(ans) >= 0:
    print(max(ans))
else:
    print(0)

Solution (Python):
N = int(input())
S = input()
x = 0
max = 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()
ans = 0
x = 0

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

Solution (Python):
n = int(input())
l = input()
ans = 0
max_ans = 0
for i in l:
  if i == 'D':
    ans -= 1
  else:
    ans += 1
  max_ans = max(ans,max_ans)
    
print(max_ans)

Solution (Python):
import sys

n, s = sys.stdin.read().split()
n = int(n)

def main():
    t = s
    t = t.replace('I', '+')
    t = t.replace('D', '-')
    x = 0
    res = 0
    for i in range(n):
        x += eval(t[i] + '1')
        res = max(res, x)

    return res

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

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

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

ans = 0
x = 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()
c=[0]
for a in s:
  if a=='I':
    c.append(c[-1]+1)
  else:
    c.append(c[-1]-1)
print(max(c))

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

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

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

Solution (Python):
def main(n: int, s: str):
    i = 0
    ans = [0]

    for s in s:
        if s == 'I':
            i += 1
        else:
            i -= 1

        ans.append(i)

    print(max(ans))


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

    main(n, s)

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

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

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

x = [0]
count = 0
for i in s:
    if i == 'I':
        x.append(x[count] + 1)
    else:
        x.append(x[count] - 1)
    count += 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
        xmax = max(xmax, x)
    elif s[i] == "D":
        x -= 1
        xmax = max(xmax, x)

print(xmax)

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

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

Solution (Python):

n = int(input())
s = input()
x = 0
num = []
num.append(x)

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

print(max(num))

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 = 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()
c=0
m=0
for i in range(len(s)):
    if s[i]=="I":
        c+=1
    else:
        c-=1
    m=max(m,c)
print(m)

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

Solution (Python):
from sys import stdin


def fetch_one_line():
    return stdin.readline().rstrip()


def fetch_int_input():
    return [int(s) for s in fetch_one_line().split()]


def fetch_inputs(times):
    return [fetch_one_line() for _ in range(times)]


def fetch_int_inputs(times):
    return [[int(s) for s in fetch_one_line()] for _ in range(times)]

sum = 0
change = {"I": 1, "D": -1}
length = int(fetch_one_line())
target = fetch_one_line()
records = [0 for _ in range(length)]

for i, t in enumerate(target):
   sum += change[t]
   records[i] = sum

max_val = max(records)
if max_val < 0:
    max_val = 0
print(max_val)

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


print(max(ans))

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


for s in ls:
    if s == 'I':
        x += 1
    else:
        x -= 1
    if ans < x:
        ans = x

print(ans)

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

ans = 0
x = 0
for c in s:
    if c == 'I':
        x += 1
    else:
        x -= 1

    ans = max(x, ans)

print(ans)

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

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

print(max(x))

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

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

for s in S:
    if s == "I":
        X += 1
    else:
        X -= 1
    X_max = max(X, X_max)

print(X_max)

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

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

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

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

test = 0

l=[0]*(n+1)

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

print(max(l))

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

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

x = 0
x_max = 0

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

print(x_max)

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

Solution (Python):
N = int(input())
result = 0
A = 0
for i in input():
  if i == "I":
    A += 1
  else:
    A -= 1
  result = (max(result,A))
print(result)

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

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):
from sys import stdin

n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()


point = 0
ma = 0
for i in s:
    if i == "I":
        point += 1
    else:
        point -= 1
    ma = max(ma,point)

print(ma)

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

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

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

for i in s:
    if i == 'I':
        ans += 1
    else:
        ans -= 1

    if ans >= max:
        max = ans

print(max)

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

ans = 0
x = 0

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

print(ans)

Solution (Python):
def judge(N,S):
    x = 0
    maxi = 0
    lst = list(S)
    for i in range(N):
        if lst[i]=="I":
            x += 1
        else:
            x -= 1
        if maxi<x:
            maxi = x
    print(maxi)

N = int(input())
S = input()
judge(N,S)

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

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

Solution (Python):
x = 0
xmax = 0
_ = input()
for si in input():
  if si == "I":
    x += 1
  elif si == "D":
    x -= 1
  xmax = max(x, xmax)
print(xmax)

Solution (Python):


N=int(input())
S=input()
maxx=0 
x=0 

for s in S:
    if s=="I": 
        x+=1
    elif s=="D": 
        x-=1

    if x>maxx: 
        maxx=x
    
print(maxx)

Solution (Python):











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N=I()
    S=ST()
    ans = 0
    now = 0
    for s in S:
        if s=="I":
            now += 1
        else:
            now -=1
        ans = max(ans,now)
    print(ans)

if __name__ == '__main__':
    main()

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

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

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

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

Solution (Python):
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    S = inputs[0]
    count = [0]

    for c in S:
        if c == 'I':
            count.append(count[-1] + 1)
        elif c == 'D':
            count.append(count[-1] - 1)
    return max(count)


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)

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

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

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

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()
c0 = 0
c1 = 0
for i in S:
    if i == "I":
        c1 += 1
    elif i == "D":
        c1 -= 1
    c0 = max(c0,c1)
    
print(c0)