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






import sys
input = sys.stdin.readline

import math

import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]


def Yes(): print("Yes"); return
def No(): print("No"); return


def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr


def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors


def lcm(a, b):
    return a * b // gcd (a, b)


def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count


def Base_10_to_n(X, n):
  if X//n:
    return Base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def Base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))


def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count




N = inputI()
S = inputS()

x = 0
MAX = 0

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

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

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

print(max(Xs))

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

    ans = max(ans, num)

print(ans)

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

Solution (Python):
n = int(input())
s = input()
ans = 0
x = 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()
ans = 0
mans = 0

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

print(mans)

Solution (Python):

N = int(input())
S = input()
x = 0
maxx = 0
for c in S:
    x += [-1, 1][c == 'I']
    maxx = max(maxx, x)

print(maxx)

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

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

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

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

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

Solution (Python):
n = int(input())
s = str(input())
ans = 0
ans_lis = [0]

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

print(max(ans_lis))

Solution (Python):
n = int(input())
s = input()
max = 0
x = 0
def check(x, max):
    if max < x:
        return x
    else:
        return max

for i in s:
    if i == "I":
        x += 1
        max = check(x, max)
    elif i == "D":
        x -= 1
        max = check(x, max)
print(max)

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()
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())
A = list(input())
B = [0]*N
C = [0]*N
for i in range(N):
  if A[i] == "I":
    B[i] = 1
  else:
    B[i] = -1
C[0] = B[0]
for i in range(1, N):
  C[i] = C[i-1]+B[i]
if max(C) < 0:
    print(0)
else:
    print(max(C))

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

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

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

Solution (Python):
N=int(input())
S=list(input())
tmp=0
max=0
for _ in range(N):
    if S.pop(0)=='I':
        tmp+=1
        if tmp>max:
            max=tmp
    else :
        tmp+=-1
print(max)

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

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

Solution (Python):
import math
import time
from collections import defaultdict, deque
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
n=int(input())
a=input()
ans=0
x=0
for i in a:
    if(i=='I'):
        x+=1
    else:
        x-=1
    ans=max(ans,x)
print(ans)

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

ans = 0
num = 0

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

    ans = max(ans, num)

print(ans)

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

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, max_x = 0, 0

for c in S:
    if c == 'I':
        x += 1
    elif c == 'D':
        x -= 1
    if x > max_x:
        max_x = x
print(max_x)

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

def Main(N, S):
    ans = 0
    mx = ans
    for c in S:
        if c == "I":
            ans += 1
        else:
            ans -= 1
        mx = max(mx, ans)
    return mx
        
res = Main(N, S)
print(res)

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

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


if __name__ == "__main__":
    main()

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

Solution (Python):
import math
def py():
    print("yes")
def pn():
    print("no")
def iin():
    x = int(input())
    return x

neko = 0
nya = 0
nuko = 0

n = iin()
s = input()
for i in s:
    if i == 'I':
        neko += 1
    elif i == 'D':
        neko -= 1
    if nuko < neko:
        nuko = neko
print(nuko)

Solution (Python):

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

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

ans = 0
current = 0

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

print(ans)

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

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

print(maxx)

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

print(m)

Solution (Python):
import sys

input = sys.stdin.readline

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

if __name__ == '__main__':
    main()

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

count = 0
ans = 0
for char in s:
    if char == "I":
        count += 1
    elif char == "D":
        count -= 1

    if ans < count:
        ans = count

print(ans)

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

Solution (Python):
import sys
import math
import bisect

def main():
    n = int(input())
    max_val = 0
    val = 0
    for c in input():
        if c == 'I':
            val += 1
        elif c == 'D':
            val -= 1
        max_val = max(max_val, val)
    print(max_val)

if __name__ == "__main__":
    main()

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

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

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

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

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

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

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

print(max(memo))

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(str(input()))
ans=0
temp=ans
for i in range(n):
  if s[i]=="I":
    temp+=1
    if temp>ans:
      ans=temp
  else:
    temp-=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
    else:
        x -= 1
    
    if  x>=m:
        m = x

print(m)

Solution (Python):


import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))

from fractions import gcd
def resolve():
    N,=pin()
    S=input()
    temp=0
    ans=0
    for s in S:
        if s=="I":
            temp+=1
        else:
            temp-=1
        ans=max(ans,temp)
    print(ans)
        

resolve()

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

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

    print(max(max(ans), 0))


resolve()

Solution (Python):
n = int(input())
s = input()
ans = 0
t = 0
hoge = 0
while t < n:
  if s[t] == 'I':
    hoge += 1
  else:
    hoge -= 1
  ans = max(ans,hoge)
  t += 1
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 = str(input())

sum =0
result =[0]

for i in range(len(S)):
    
    if S[i]=="I":
        sum +=1
    else:
        sum = sum -1
    
    result.append(sum)
    
result.sort()


print(result[len(result)-1])

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

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

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

x = 0

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

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

print(max(l))

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

print(max(X))

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 accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
import numpy as np

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

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

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

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

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

cnt = 0
max = 0

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

print(max)

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

Solution (Python):
ans=0
tmp=0
n=int(input())
s=input()
for i in range(n):
    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
hantei=0
for i in s:
  if i=="I":
    ans+=1
  elif i=="D":
    ans-=1
  if ans>hantei:
    hantei=ans
  
print(hantei)

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

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

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

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

print(ans)

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

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

x = 0
tmpmax = 0
for s in S:
  if s == "I":
    x += 1
  elif s == "D":
    x -= 1
  
  tmpmax = max(tmpmax, x)

print(tmpmax)

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

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

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

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

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):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7


sm=0
n=I()
mx=0
s=input().rstrip()
for i in range(n):
    if s[i]=="I":
        sm+=1
    else:
        sm-=1
    if sm>mx:
        mx=sm
print(mx)

Solution (Python):
n = int(input())
s = input()
x = 0
ans = 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 =input()

now = 0
temp = 0

sl = list(s)

for i in sl:
    if i =="I":
        now += 1
    else:
        now -=1
    temp = max(temp,now)

print(temp)

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

    memo = [0]*(N+1)
    for i, ss in enumerate(S, 1):
        if ss == 'I':
            memo[i] = memo[i-1] + 1
        else:
            memo[i] = memo[i-1] - 1

    print(max(memo))


if __name__ == "__main__":
    main()

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

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

Solution (Python):
N = int(input())
S = str(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 = input()

n = 0

ans = 0
for c in s:
    if c == "I":
        n += 1
    else:
        n-=1
    if ans < n:
        ans = n

print(ans)

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

Solution (Python):
N=int(input())
s=input()
i_count=0
max_count=0
for i in range(N):
    if s[i]=="I":
        i_count+=1
        if i_count>max_count:
            max_count=i_count
    if s[i]=="D":
        i_count-=1
print(max_count)

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

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

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

x=0
Ans=0

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

print(Ans)

Solution (Python):
N = input()
S = list(input())
cnt = 0
cnt_max = 0
for i in S:
  if i == 'I':
    cnt += 1
    if cnt > cnt_max:
      cnt_max = cnt
  elif i == 'D':
    cnt -= 1
print(cnt_max)

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

Solution (Python):
import copy
N = int(input())
S = input()
m = 0
x = 0
for p in S:
    if p == 'I':
        x += 1
    if p == 'D':
        x -= 1
    if x > m:
        m = copy.deepcopy(x)
print(m)

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

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

print(max(ans))

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

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

print(max(ans))

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

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

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

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

if '__main__' == __name__:
    resolve()

Solution (Python):
A = int(input())
B = list(input())
ans = 0
now = 0
for i in range(A):
    if B[i] == "I":
        now += 1
    else:
        now -= 1
    ans = max(ans,now)
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 = list(map(str, input()))
x = 0
answer = 0

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

print(answer)

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

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

ans = 0
x = 0

for s in S:
    if s == 'I':
        x += 1
        if ans < x:
            ans = x
    elif s == 'D':
        x -= 1

print(ans)

Solution (Python):


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

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

Solution (Python):

x = 0
lst = [0]
n = int(input())
s = list(input())

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

print(max(lst))

Solution (Python):

x = 0
lst = [0]
n = int(input())
s = list(input())

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

print(max(lst))

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

Solution (Python):
import numpy as np
import sys

input = sys.stdin.readline

N = int(input())

S = input()

res = 0

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

print(res)

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

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

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

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

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

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
  elif (s[i] == 'D'):
    x -= 1
print (max)

Solution (Python):
n = int(input())
s = 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 = list(input())

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

print(ans)

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

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

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

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

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

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

if __name__ == '__main__':
    main()

Solution (Python):
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    S = list(iss())
    ret = 0
    tmp = 0
    for s in S:
        if s == 'I':
            tmp += 1
        else:
            tmp -= 1
        ret = max(ret, tmp)
    print(ret)


if __name__ == '__main__':
    main()

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

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

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

for c in s:
  if c == "I":
    x += 1
  else:
    x -= 1
  if x > ans:
    ans = x

print(ans)

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

cnt = 0
ans = 0
for si in S:
    if si == 'I':
        cnt += 1
        ans = max(ans, cnt)
    elif si == 'D':
        cnt -= 1
print(ans)

Solution (Python):
N=input()
S=input()
max_v =0
v =0
for i in S:
  if i=="I":
    v+=1
    if v>max_v:
      max_v=v
  else:
    v-=1
print(max_v)

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


def main():
    n = int(input())
    s = input()
    x = 0
    yield x
    for c in s:
        if c == "I":
            x += 1
            yield x
        else:
            x -= 1
            yield x

print(max(main()))