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):
def main():
    N = int(input())
    S = input()
    ans = 0
    cur = 0
    for s in S:
        if s == "I":
            cur += 1
        else:
            cur -= 1
        ans = max(cur, ans)
    print(ans)


if __name__ == '__main__':
    main()

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

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

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

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

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

Solution (Python):

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

x = [0 for _ in range(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 = str(input())

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

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

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

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

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

print(ans)

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

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

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

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

max_num = 0
for i in s:
    if i == "I":
        x += 1
    else:
        x -= 1

    max_num = max(max_num, x)

print(max_num)

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

l = [0]*(n+1)
if s[0] == "I":
    l[0] = 1
else:
    l[0] = -1

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

print(max(l))

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

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

sum_ = 0
ans = 0
for n in range(N):
  if s[n]=="I":
    sum_ += 1
  else:
    sum_ -= 1
  if ans < sum_:
    ans = sum_
print(ans)

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

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

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

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

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

print(max(list))

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

print(max(count))

Solution (Python):

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

for i in range(N):
    if S[i]=='I':
        cnt +=1
        x = max(x,cnt)
    elif S[i]=='D':
        cnt -=1
        x = max(x,cnt)
print(x)

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

Solution (Python):
input()
a=[0]
for i in input():a+=a[-1]+1-2*(i=='D'),
print(max(a))

Solution (Python):
input()
x=0
a=[0]
for i in input():a+=a[-1]+1-2*(i=='D'),
print(max(a))

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

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

ans=[0]*N
tmp=0

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

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()
list1 = []
for counter in range(n + 1):
    d = s.count("D", 0, counter)
    i = s.count("I", 0, counter)
    number = i - d
    list1.append(number)

if max(list1) <= 0:
    print(0)
else:
    print(max(list1))

Solution (Python):
n = int(input())
s = input()
list1 = []
for counter in range (n+1):
  d = s.count("D",0,counter)
  i = s.count("I",0,counter)
  number = i-d
  list1.append(number)

if max(list1) <=0:
  print(0)
else:
  print(max(list1))

Solution (Python):
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd



import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


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


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


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


if __name__ == '__main__':
    main()

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

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

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

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

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    II()
    s=SI()
    t=0
    ans=0
    for c in s:
        if c=="I":t+=1
        else:t-=1
        ans=max(ans,t)
    print(ans)

main()

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

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

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

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

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

Solution (Python):

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

Solution (Python):

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

def main():
    mod=10**9+7
    x=0
    N=I()
    S=input()
    
    ans=0
    for i in range(N):
        if S[i]=="I":
            x+=1
        else:
            x-=1
            
        ans=max(ans,x)
        
    print(ans)

main()

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

peak.sort()
print(peak[-1])

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








def resolve():
    N=int(input())
    S=str(input())
    val=0
    valmax=0

    for i in range(N):
        if S[i]=='I':
            val+=1
            valmax = max(valmax, val)

        else:
            val-=1

    print(valmax)




resolve()

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

print(y)

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

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

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

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

Solution (Python):



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


max_score = 0
tmp = 0


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

print(max_score)

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

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

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

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

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

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

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

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

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

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

print(ans)

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

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

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

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

Solution (Python):
import sys

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline
    n=int(readline().strip())
    ss=readline().strip()
    x=0
    maxx=x
    for s in ss:
      diff=1 if s=="I" else -1
      x+=diff
      maxx=max(maxx,x)
    print(maxx)

    return


resolve()

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

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

print(ans)

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

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

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

x = 0
for i in S:
    if i == 'I':
        x += 1
        if max < x:
            max = x
        else:
            max = max
    else:
        x -= 1

print(max)

Solution (Python):


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

max_count = 0
curr_count = 0

for s in S:
    if s == 'I':
        curr_count += 1

    elif s == 'D':
        curr_count -= 1

    if curr_count > max_count:
        max_count = curr_count

print(max_count)

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

Solution (Python):
import sys









mod = int(1e9+7)
INF = 1<<29

def main():
    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)
    return

if __name__=='__main__':
    main()

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

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

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

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

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

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

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

print(max(ans))

Solution (Python):


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


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

print(x_max)

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

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

ans = []
x = 0

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

print(max(ans[0],0))

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

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

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

x,y = 0,0
for i in range(n):
    if l[i] == 'I':
        x += 1
        y = max(x,y)
    elif l[i] == 'D':
        x -= 1

print(y)

Solution (Python):

n=int(input())
s=input()
print(max([s[:i].count('I')-s[:i].count('D') for  i in range(n+1)]))

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(x,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
    if s[i] == "D":
        cnt -= 1
    ans = max(ans, cnt)

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

print(s)

Solution (Python):
N = int(input())
S = input()
ans = 0
now = 0
for s in S:
  if s == 'I':
    now +=1
  elif s=='D':
    now -=1
  if now > ans:
    ans = now
print(ans)

Solution (Python):
input()
s=input()
n,m=0,0

for i in range(len(s)):
  if s[i]=="I":
    n+=1
    m=max(n,m)
  if s[i]=="D":
    n=n-1
    m=max(n,m)
print(m)

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

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

Solution (Python):
import sys
readline = sys.stdin.buffer.readline
数字 = int(readline())
文字 = readline().rstrip().decode('utf-8')

答え = 0
答えの最大値 = 0

for 文字の1要素 in 文字:
    if 文字の1要素 == "I":
        答え += 1
        答えの最大値 = max(答えの最大値,答え)
    else:
        答え -= 1

print(答えの最大値)

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
		ans=max(ans,tmp)
print(ans)

Solution (Python):

import sys


def solve(N: int, S: str):
    x = 0
    mx = 0
    for Si in S:
        x += 1 if Si == "I" else -1
        mx = max(mx, x)
    print(mx)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    S = next(tokens)  
    solve(N, S)


if __name__ == '__main__':
    main()

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

Solution (Python):
def main():
    length = int(input())
    string = input()
    answer = 0
    integer = 0
    for s in string:
        if s == "I":
            integer += 1
        else:
            integer -= 1
        answer = max(answer, integer)
    print(answer)


if __name__ == '__main__':
    main()

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

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

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

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

x = 0
answer = 0
for c in S:
  if c == 'D':
    x -= 1
  else:
    x += 1
  answer = max(answer,x)

print(answer)

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

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

Solution (Python):
n = int(input())
l = list(input())
x = 0
ans = 0
for i in l:
  if 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
    else:
        x -= 1
    ans = max(ans, x)
print(ans)

Solution (Python):
n=int(input())
s=input()
x=0
max_x=0
for op in s:
    if op=="I":
        x+=1
    if op=="D":
        x-=1
    if max_x<x:
        max_x=x

print(max_x)

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

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

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

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

Solution (Python):
input()
S = input()
total = answer = 0
for c in S:
    total += (1 if c == "I" else -1)
    answer = max(answer, total)
print(answer)

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

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

print(max(x))

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

x = 0

max = x

for s in S:
    if s == 'I':
        x += 1
    else:
        x -= 1
    if max < x:
        max = x

print(max)

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

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

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

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

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

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

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

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

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

Solution (Python):
N = int(input())
S = list(input())
xmax = 0
now = 0
for i in range(N):
    if S[i] == "I":
        now += 1
    elif S[i] == "D":
        now -= 1
    if now > xmax:
        xmax = now
print(xmax)

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

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

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

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

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

Solution (Python):
input()
s = input()
t,a = 0,0
for c in s:
  t += 1-(c=='D')*2
  a = max(a,t)
print(a)

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

c = 0
ans = 0

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

print(ans)

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

Solution (Python):
N = int(input())
S = input()
ans = 0
t = 0
for s in S:
    if s == 'I':
        t += 1
        if t > ans:
            ans = t
    else:
        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=input()
count=0
max=0
for i in range(N):
    if S[i]=="I":
        count=count+1
    elif S[i]=="D":
        count=count-1

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

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

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

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

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

ans = 0
mx = 0

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

Solution (Python):
n = int(input())
s = input()
ans = 0
now = 0
d = {'I': 1, 'D': -1}
for c in s:
  now += d[c]
  ans = max(ans, now)
print(ans)

Solution (Python):
a=int(input())
b=input()
for x in b:
    b=b.replace("DI","")
print(b.count("I"))

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

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

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

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

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

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

Solution (Python):




def main():
    N = int(input())
    S = input()
    x = 0
    xm = 0
    for i in range(N):
        if S[i] == 'I':
            x+=1
        else :
            x-=1
        if xm < x:
            xm = x
    print(xm)


if __name__ == "__main__":
    main()

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

Solution (Python):
n = int(input())
str = input()
answer = 0
count = 0
for id in range(n):
    if str[id] == "I": count += 1
    elif str[id] == "D": count -= 1
    answer = max(answer, count)

print(answer)

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

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

Solution (Python):

n = int(input())
s = list(str(input()))

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

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

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

Solution (Python):
x = 0
ans = 0

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

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

print (ans)

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

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

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