Problem:
 Score : 200 points    Problem Statement You have an integer variable x .
Initially, x=0 .  Some person gave you a string S of length N , and using the string you performed the following operation N times.
In the i -th operation, you incremented the value of x by 1 if S_i= I , and decremented the value of x by 1 if S_i= D .  Find the maximum value taken by x during the operations (including before the first operation, and after the last operation).      Constraints  1≤N≤100  |S|=N  No characters except I and D occur in S .         Input The input is given from Standard Input in the following format:  N  S       Output Print the maximum value taken by x during the operations.        Sample Input 1 5
IIDID      Sample Output 1 2  After each operation, the value of x becomes 1 , 2 , 1 , 2 and 1 , respectively. Thus, the output should be 2 , the maximum value.       Sample Input 2 7
DDIDDII      Sample Output 2 0  The initial value x=0 is the maximum value taken by x , thus the output should be 0 .

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

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

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

Solution (Python):

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

maxim = 0
count = 0
for i in S:
    if i == 'I':
        count += 1
    else:
        count -= 1
    if maxim < count:
        maxim = count
print(maxim)

Solution (Python):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n = ri()
max_ = 0
cur = 0
for i in rr():
    if i == 'D':
        cur -= 1
    if i == 'I':
        cur += 1
    max_ = max(cur, max_)
print(max_)

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

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

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

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

x = 0
ans = 0

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

print(ans)

Solution (Python):
n = int(input())
s = input()
count = 0
count_list = [0]

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

print(max(count_list))

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

ans = 0
tmp = 0

for si in S:
    tmp += [-1,1][si=='I']
    ans = max(ans,tmp)

print(ans)

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

x = [0] * 101
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):
import os
import sys
import math
if os.environ.get("DEBUG") is not None:
    sys.stdin = open("in.txt", "r")
rl = sys.stdin.readline

n, s = [rl().rstrip("\n") for _ in range(2)]
x = 0
ans = 0
for it in s:
    if it == "I":
        x += 1
    else:
        x -= 1
    ans = max(ans, x)
print(ans)

Solution (Python):
import os
import sys
import math
if os.environ.get("DEBUG") is not None:
    sys.stdin = open("in.txt", "r")
rl = sys.stdin.readline

n, s = rl().rstrip("\n"), rl().rstrip("\n")
x = 0
ans = 0
for it in s:
    if it == "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
    ans = max(ans, x)
  else:
    x -= 1
    ans = max(ans, x)
print(ans)

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

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

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()
x = 0
c = 0
x1 = 0
t = []
for i in s:
	if i=='I':
		c+=1
	if c>x:
		x =c
	elif i=='D':
		c-=1
	if c>x1:
		x1=c

	t.append(max(x1,x))
print(max(t))

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

x = 0
x_max = 0

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

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

Solution (Python):
x = 0
maxX = 0

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

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

print(maxX)

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

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

x = 0
ans = 0

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

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

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

Solution (Python):







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

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

Solution (Python):







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

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

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

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

Solution (Python):
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()
s = input()

x = 0
ans = 0

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

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

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

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

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

ans = 0
ans_max = 0
for i in s:
    if i == "I":
        ans += 1
    else:
        ans -= 1
    if ans > ans_max:
        ans_max = ans

print(ans_max)

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

print(max(ls))

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

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

res = 0
t = 0

for s in S:
    if s == "I":
        t += 1
    else:
        t -= 1

    res = max(res, t)

print(res)

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

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

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
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
import numpy as np
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

N = INT()
S = input()

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

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

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

Solution (Python):
def resolve():
    N = input()
    S = input()
    x = 0
    max_x = 0
    for i in range(len(S)):
        if S[i] == "I":
            x += 1
            if x > max_x:
                max_x = x
        elif S[i] == "D":
            x -= 1
    print(max_x)

resolve()

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

Solution (Python):
n=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()

Sum = 0
Max = 0

for s in S:
    Sum += (-1)**(s == 'D')
    Max = max(Sum, Max)

print(Max)

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

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

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

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

res = 0
v = 0
for c in s:
    if c == 'I':
        v += 1
    else:
        v -= 1
    res = max(res, v)

print(res)

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

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

Solution (Python):
N= map(int,input().split())
S = input()
syukei = [0,]
num = 0
count = 0
while len(S) > count:
    for i in S:
        count +=1
        if i == 'I':
            num +=1
            syukei.append(num)
        else:
            num -=1
            syukei.append(num)

print(max(syukei))

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

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

print(x)

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

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

Solution (Python):

import math

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

print(ans)

Solution (Python):


def main():

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

    listS = list(S)
    x = 0
    listNum = [x]

    for i in listS:
        if i == 'I':
            x += 1
            listNum.append(x)

        elif i == 'D':
            x += -1
            listNum.append(x)

    ans = max(listNum)
    print(ans)


if __name__ == "__main__":
    main()

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

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

print(maxV)

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

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

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

Solution (Python):
d={"I":+1,"D":-1}
input()
s=input()
maxx=0
x=0
for c in s:
  x+=d[c]
  maxx=max(x,maxx)
print(maxx)

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

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

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

Solution (Python):
input()
s = input()
while "DI" in s:
    s = s.replace("DI", "")
print(s.count("I"))

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

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    S = readline().strip()

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

    print(ans)
    return


if __name__ == '__main__':
    main()

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

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

print(nax)

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

Solution (Python):
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LS2(): return list(sys.stdin.readline().rstrip())  

N = I()
S = LS2()

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

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    S = SS()

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

    print(ans)

if __name__ == '__main__':
    resolve()

Solution (Python):
N = int(input())
S = input()
sum = ""
li = []
for s in S:
    sum += s
    li.append(sum)

ic = 0
dc = 0
ma = 0
for l in li:
    ic = l.count("I")
    dc = l.count("D")
    ma = max(ma, ic - dc)
    
print(ma)

Solution (Python):
from collections import deque

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

d={'I':1, 'D':-1}
l=[0]*(N+1)

for x in range(1,N+1):
  l[x]=l[x-1]+d[S[x-1]]

print(max(l))

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

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

Solution (Python):
def main():
    n = int(input())
    s = input()
    x = 0
    tmp = 0
    for i in range(len(s)):
        if(s[i]=="D"):
            x-=1
        if(s[i]=="I"):
            x+=1
        tmp = max(tmp,x)
    print(tmp)
if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
MM = input()
x = 0
maxi = 0
for i in MM:
  if i =='D':
    x -=1
  else:
    x +=1
    if x > maxi:
      maxi = x
print(maxi)

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

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

print(ans)

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

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

print(ans)

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

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

Solution (Python):

N = int(input())
S = list(input())
count = 0
max = 0
for i in range(N):
  if S[i] == 'D':
    count -= 1
  elif S[i] == 'I':
    count += 1
  if count > max:
    max = count
print(max)

Solution (Python):

N = int(input())
S = 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

print(Max)

Solution (Python):
def main():
    N = int(input())
    S = list(input().rstrip())
    vals = [0]
    for s in S:
        if s == "I":
            vals.append(vals[-1] + 1)
        else:
            vals.append(vals[-1] - 1)
    print(max(vals))


if __name__ == '__main__':
    main()

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

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

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

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

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

words = list(s)
x = 0
max_x = 0
n = int(p)

for num in range(len(words)):
    if words[num] == 'I':
        x += 1
        if x > max_x:
            max_x = x
    else:
        x -= 1

print(max_x)

Solution (Python):


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    x = 0
    max_x = 0
    n = read_int()
    for c in input().strip():
        if c == 'I':
            x += 1
        else:
            x -= 1
        max_x = max(max_x, x)
    return max_x


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

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

ans,x = 0,0

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

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

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

Solution (Python):
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

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

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

print(ans)

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



s=list(input())

x=0
mx=0

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

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

print(m)

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

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

Solution (Python):
N=int(input())
S=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(n):
    if s[i]=='I':
        x+=1
        ans.append(x)
    else:
        x-=1
        ans.append(x)
print(max(ans))

Solution (Python):

_, s = open(0).read().split()

print(
    max([sum(1 if i == "I" else -1 for i in s[:j+1])
         for j in range(int(_))] + [0]))

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

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

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

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

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

Solution (Python):
import sys
import numpy as np
import random
from decimal import Decimal
import itertools
import re
import bisect
from collections import deque, Counter
from functools import lru_cache

sys.setrecursionlimit(10**9)
INF = 10**13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
def SERIES(n): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ')
def GRID(h,w): return np.fromstring(sys.stdin.buffer.read(), dtype=np.int32, sep=' ').reshape(h,-1)[:,:w]
def GRIDfromString(h,w): return np.frombuffer(sys.stdin.buffer.read(), 'S1').reshape(h,-1)[:,:w]
MOD = 1000000007

def main():
	n = I()
	s_list = list(S())
	x = 0
	x_max = 0
	for s in s_list:
		if s == 'I':
			x += 1
		else:
			x -= 1
		x_max = max(x, x_max)
	print(x_max)


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
S = str(input())
mx = 0
x = 0
for i in range(len(S)):
    if S[i] == 'D':
        x -= 1
    else:
        x += 1
    if mx < x:
        mx = x
        
print(mx)

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

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

print(max(xs))

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

x, ans = 0, 0

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

Solution (Python):
n,s = open(0).readlines()

tmp = 0
ans = 0

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

print(ans)

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

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 = max(l,x)

print(l)

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

x = 0
x_max = 0

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

print(x_max)

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

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

print(max_x)

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

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

print(ans)

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

ans = x

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

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

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


x = 0
max_x = 0

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

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

print(max_x)

Solution (Python):









import sys
input = sys.stdin.readline

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

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

print(ans)

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

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

print(ans)

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

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

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

x = 0
x_max = 0
s_list = []

for i in s:
    s_list.append(i)



for i in s_list:
    if i == 'I':
        x += 1
        if x > x_max:
            x_max = x
    elif i == 'D':
        x -= 1


print(x_max)

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()
a=t=0
for c in input():
  t+=(c>'D')*2-1
  a=max(a,t)
print(a)

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

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

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

Solution (Python):
N = int(input())
line = list(input())
maxNum = 0
cur = 0
for i in line:
    if i == 'I':
        cur += 1
    else:
        cur -= 1
    maxNum = max(maxNum, cur)
print(maxNum)

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

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

    if ans < x:
        ans = x

print (ans)

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

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

x = 0
max_x = 0
for s in S:
    if s =="I":
        x += 1
    else:
        x -= 1
    if x > max_x:
        max_x = x

print(max_x)

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

Solution (Python):
n = int(input())
s = input()
ans = [0]
x = 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):
_ = input()
s = input()
tmp=0
ans=[0]
for i in s:
    if i == 'D':
        tmp-=1
    else:
        tmp+=1
    ans.append(tmp)
print(max(ans))

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