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):
x=int(input())
s=input()
x=0
l=[0]
for i in s:
  if i=='I':
    x+=1
    l.append(x)
  elif i=='D':
    x-=1
    l.append(x)
print(max(l))

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

Solution (Python):
import numpy as np

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

a = np.array([1 if i == 'I' else -1 for i in list(s)])
print(max(a.cumsum().max(), 0))

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

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

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

print(ans)

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

for c in s:
  if c=="I":
    x+=1
  else:
    x-=1
  if max<x:
    max=x

print(max)

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

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

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

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

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

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

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

print(ans)

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

print(max(temp))

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

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

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

print(ans)

Solution (Python):
from itertools import accumulate

N = int(input())
As = [1 if S == 'I' else -1 for S in input()]

print(max(accumulate([0] + As)))

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

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

y = 0
for sss in S:
    if sss == 'I':
        x += 1
    elif sss == 'D':
        x -= 1
    if x > y:
        y = x
print(y)

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

Solution (Python):
N = int(input())
S = str(input())
lst_for_ans = []
for i in range(len(S)+1):
       I_count = S[:i].count("I")
       D_count = S[:i].count("D")
       lst_for_ans.append(I_count - D_count)

print(max(max(lst_for_ans),0))

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

Solution (Python):
int_n = int(input())
str_s = input()

int_x = 0
li_x = list()
li_x.append(int_x)
for s in str_s:
    if s == "I":
        int_x += 1
    else:
        int_x -= 1
    li_x.append(int_x)
print(max(li_x))

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

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

A = []

for i in range(n+1):
    ans = s[:i]
    A.append(ans.count('I') - ans.count('D'))

print(max(A))

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

ans = max(ans, temp)

print(ans)

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

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

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

x = 0
ans = 0








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

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

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

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

Solution (Python):
n=int(input())
k=list(input())
c=0
d=0
for i in range(n):
    if k[i]=="D":
        c-=1
    else:
        c+=1
        d=max(c,d)
print(d)

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

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

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

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

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

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

Solution (Python):
def main():
    x = x_max = 0
    _ = input()
    for c in input():
        if c == 'I':
            x += 1
            x_max = max(x_max, x)
        else:
            x -= 1
    print(x_max)


if __name__ == '__main__':
    main()

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

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

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

print(xmax)

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

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

Solution (Python):
N = int(input())
S = input()
max_value = 0
current_value = 0
for i in range(len(S)) :
    if (S[i] == 'I') :
        current_value += 1
        if (max_value < current_value) :
            max_value = current_value
    else :
        current_value -= 1

print(max_value)

Solution (Python):



def main():
    """Function."""
    n = int(input())
    s = str(input())

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

    print(max(counter))


if __name__ == "__main__":
    main()

Solution (Python):
import numpy
N = input()
c_to_i = {'I': 1, 'D': -1}
x = [0] + [c_to_i[c] for c in raw_input()]
print max(numpy.cumsum(x))

Solution (Python):
import numpy
N = input()
x = [0] + [1 if c == 'I' else -1 for c in raw_input()]
print max(numpy.cumsum(x))

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

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

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

for i in s:
  if i=="I":
    x +=1
  else:
    x -= 1
  tmp=max(x,tmp)
print(tmp)

Solution (Python):
N = int(input())
S = input()
max_ = 0
x = 0
for e in S:
    if e == "I":
        x += 1
    elif e == "D":
        x -= 1
    if x > max_:
        max_ = x
print(max_)

Solution (Python):

"""
N=int(input())

print(800*N-int(N/15)*200)
"""

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

max_n=0
temp=0
for strng in S:
	if strng=="I":
		temp+=1
		if max_n<temp:
			max_n=temp
	else:
		temp-=1
print(max_n)

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

Solution (Python):
import sys

N = int(sys.stdin.readline().strip())
S = sys.stdin.readline().strip()

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

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):
input()
tmp = x = 0
for a in input():
  x += int(a.replace('I','1').replace('D','-1'))
  if tmp < x:
    tmp = x

print(max([0,tmp]))

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
    elif(S[i]=="D"):
        x-=1

print(Max)

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

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

print(ans)

Solution (Python):
def abc052_b():
    n = int(input())
    s = str(input())
    now, ans = 0, 0
    for char in s:
        if char == 'I':
            now += 1

            if now >= ans:
                ans = now
        else:
            now -= 1

    return ans


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

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, S = int(input()), input()
d = {"I":1, "D":-1}

val = 0
ans = 0
for x in S:
    val += d[x]
    ans = max(ans, val)
print(ans)

Solution (Python):

N, S = int(input()), input()
d = {"I":1, "D":-1}

val = 0
ans = 0
for x in S:
    val += d[x]
    if val > ans:
        ans = val
print(ans)

Solution (Python):
N = int(input().rstrip())
S = input().rstrip()
n = 0
c = 0
for i in range(len(S)):
    if S[i] == 'I':
        c += 1
    else:
        c -= 1

    if n < c:
        n = c

print(n)

Solution (Python):
import sys
import math
import collections
import itertools
import array
import inspect


sys.setrecursionlimit(1000000)



def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))



def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v



def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk



def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False



dp = None


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

    c = 0
    ans = 0

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

    print(ans)


main()

Solution (Python):
count = int(input())
line = [i for i in input()]
x = 0
emp = []
result = 0
for j in range(count):
    if line[j] == "I":
      x += 1
    else:
      x -= 1
    emp.append(x)  
for j in range(len(emp)):
    if result < emp[j]:
        result = emp[j]
print(result)

Solution (Python):
a=int(input())
max=0
work=0
line=input()
for i in range(a):
    if line[i:i+1] == "I":
        work+=1
    else:
        if max < work:
            max = work
        work-=1
if max < work:
    max = work
print(str(max))

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

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

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

x = 0
y = [0]

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

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

Solution (Python):
N = int(input())
s = input()
S = list(s)
x = 0
p = 0
while(S.__len__() > 0):
    if S.pop(0) == 'I':
        x += 1
        if x >= p:
            p = x
    else:
        x -= 1
print(p)

Solution (Python):
N = int(input())
s = input()
S = list(s)
x = 0
p = 0
while(S.__len__() > 0):
    if S.pop(0) == 'I':
        x += 1
        if x >= p:
            p = x
    else:
        x -= 1
print(p)

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

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

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


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

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

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

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

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

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

print(max(alist))

Solution (Python):
n = input()
s = input()
x = 0
y = 0

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

print(y)

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

Solution (Python):

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

point = 0
cum_sum = [0]

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

Solution (Python):

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

res = 0
point = 0
for i in s:
    if i == "I":
        point += 1
    else:
        point -= 1
    if res < point:
        res = point
else:
    print(res)

Solution (Python):
a = int(input())
count = 0
l = list(input())
ar = [0]
for r in l:
    if r == "I":
        count += 1
    else:
        count -= 1
    ar.append(count)
print(max(ar))

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

Solution (Python):

""" Increment Decrement """

N = int(input())
S = input()
x = 0
test = False


def answer(ori_x, s):
    """ 文字列 s から i 回目の計算結果のリストを作り、その中の最大値を返す。"""
    temp_x = ori_x
    l = [ori_x]

    for I_or_D in s:
        if I_or_D == 'I':
            temp_x += 1
        elif I_or_D == 'D':
            temp_x -= 1
        else:
            print('error')
            break
        l.append(temp_x)

    if test:
        print('l =', l)

    return max(l)


def main():
    ''' 関数に値を適用 '''
    print(answer(x, S))


if __name__ == '__main__':
    main()

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

current_num_max=0
current_num=0
text = list(S)
for c in text:
    if c == 'I':
        current_num+=1
    else:
        current_num-=1

    if current_num > current_num_max:
        current_num_max = current_num

print(current_num_max)

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

    if max < counter:
        max = counter

print(max)

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

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

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

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

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

Solution (Python):
n = int(input())
s = input()
res = 0
maxer = 0

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

	if maxer < res:
		maxer = res
else:
	print(maxer)

Solution (Python):
from sys import stdin


def main():
    n = next_int()
    s = next_str()

    maximum_value = 0
    cnt = 0

    for i in range(n):
        cnt += calc(s[i])
        maximum_value = max(maximum_value, cnt)

    print(maximum_value)


def calc(c: chr) -> int:
    if c == 'I':
        return 1
    if c == 'D':
        return -1
    return 0


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

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

x, ans = 0, 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()
ans = 0
x = 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
        if m < x:
            m = x
    else:
        x -= 1

print(m)

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

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

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

print(max(ans))

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

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

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

print(res)

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

x = 0
t = [0]

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

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

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

x=0
maxX=0
index=0
while index < len(listS):
    if listS[index] == "I":
        x+=1
    else:
        x-=1
    if x > maxX:
        maxX =  x
    index+=1

print(maxX)

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

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

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

print(xMax)

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


print(ans)

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

    if ans < x:
        ans = x
print(ans)

Solution (Python):
input()
S = list(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()
x = 0
add = [0]
for j in S:
    if j == 'I':
        x += 1
        add.append(x)
    elif j == 'D':
        x -= 1
        add.append(x)
print(max(add))

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

Solution (Python):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


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


if __name__ == '__main__':
    main()

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

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

final_ans = 0
temp_ans = 0
for s in input_s:

    if   s == 'I':
        temp_ans += 1
    elif s == 'D':
        temp_ans -= 1
    if final_ans < temp_ans:
        final_ans = temp_ans

print(final_ans)

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

Solution (Python):
N=int(input())
S=list(input())
x=0
L=[x]
for i in range(len(S)):
    if S[i]=='I':
        x+=1
        L.append(x)
    if S[i]=='D':
        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
    if ans < x:
        ans = x
print(ans)

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

Solution (Python):
N=int(input())
S=input()
x=0
a=[0]
for i in range(N):
    if S[i]=='I':
        x+=1
    elif S[i]=='D':
        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):
x = [0]
N = int(input())
S = list(input())
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
l = [x]
for i in s:
  x += (1 if i == "I" else -1)
  l.append(x)
print(max(l))

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

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

X = [0]
x = 0

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

print(max(X))

Solution (Python):

import sys
stdin = sys.stdin

def li(): return [int(x) for x in stdin.readline().split()]
def li_(): return [int(x)-1 for x in stdin.readline().split()]
def lf(): return [float(x) for x in stdin.readline().split()]
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(ns())
def nf(): return float(ns())

n = ni()
s = lc()

res = 0
ans = 0
for c in s:
    if c == "I":
        res += 1
        
        if res > ans:
            ans = res
            
    elif c == "D":
        res -= 1
        
print(ans)

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

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

res = 0
m = 0

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

print(m)

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

Solution (Python):
input();
s=t=0;
for c in input():
    if c=='I':t+=1
    if c=='D':t-=1
    s=max(s,t)
print(s)

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

x = 0
max_x = 0

for c in s:
    if c == 'I':
        x += 1
        if x > max_x:
            max_x = x
    else:
        x -= 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):
from collections import Counter
N = int(input())
A = input()
count = 0
count_max = 0
for i in range(N):
    if A[i] == 'I':
        count += 1
    else:
        count -= 1
    count_max = max(count, count_max)
print(count_max)

Solution (Python):
N = int(input())
S = list(input())
value, ans = 0, 0
for word in S:
    if word == 'I':
        value += 1
    else:
        value -= 1
    ans = max(ans, value)

print(ans)

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

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

print(ans)

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

ruiseki = [0]

for i in range(len(S)):
    if S[i] == "I":
        ruiseki.append(ruiseki[i] + 1)
    elif S[i] == 'D':
        ruiseki.append(ruiseki[i] - 1)

print(max(ruiseki))

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

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

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

for i in s:
    if i == "I":
        x += 1
    else:
        x -= 1
    x_max = max(x, x_max)

print(x_max)

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

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

    xmax = max(xmax, x)
    
print(xmax)

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

a = list(S)

max_count = 0
count = 0

for i in a:
    if i == "I":
        count += 1
        if max_count <= count:
            max_count = count
    else:
        count -= 1

print(max_count)

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

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