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.



Sample input:
5
IIDID


Sample output:
2

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = list(input())
count = 0
a = set()
for i in range(n):
    if ans[i] == 'I':
        count += 1
        a.add(count)
    elif ans[i] == 'D':
        count -= 1
        a.add(count)

print(max(a))

Submission status: Wrong Answer

Solution code:
n = int(input())
ans = list(input())
count = 0

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

Submission status: Wrong Answer

Solution code:
n=int(input())
x=0
b=[]
s=input()
for S in s:
    if S=='I':
        x += 1
        b.append(x)
    else:
        x -= 1
        b.append(x)
print(max(b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

max_num = 0
idx = 0
x = 0
while idx < N - 1:
    if S[idx] == 'I':
        x += 1
    else:
        x -= 1
    max_num = max(x, max_num)
    idx += 1

print(max_num)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(input())
count = 0
max = 0
for i in range(n):
  if max < count:
    max = count
  if s[i] == "I":
    count += 1  
  elif s[i] == "D":
    count -= 1
print(max)

Submission status: Wrong Answer

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

ans = 0
highest = 0
for i in S:
    if i == "I":
        ans += 1
    else:
        ans -= 1
    print(ans)
    if highest <= ans:
        highest = ans 

print(highest)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
x = 0
 
for i in S:
  if i == "I":
    x += 1
  elif i == "D":
    x -= 1
print(x)

Submission status: Wrong Answer

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

i_cnt = s.count('I')
d_cnt = s.count('D')

ans = max(0, (i_cnt - d_cnt))
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
m,c = 0,0
for l in raw_input():
	c += 1 if l == 'I' else -1
	m = max(c,m)
print m

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
firstline = int(input())
sec = input()
maxN = 0
init = 0

for i in sec:
  if i == "I":
    init -= 1
  else:
    init += 1
  if init > maxN:
    maxN = init
    
print(maxN)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
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)]
print(n, s)
x = 0
ans = 0
for it in s:
    if it == "I":
        x += 1
    else:
        x -= 1
    ans = max(ans, x)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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 = S.count("I") - S.count("D")
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

def main():

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

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

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

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

    ans = max(listNum)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
a = 0
for i in range(N):
    a = max(a,S[:i].count('I')-S[:i].count('D'))
print(a)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n=input();s=input();print(s.count('I')-s.count('D')+1)

Submission status: Wrong Answer

Solution code:
n=input();s=input();print(sum([[-1,1][i=='I'] for i in s])+1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
N = int(input())
S = str(input())
if N <= 0 or N >= 100:
    sys.exit()
x = 0
max = 0
for I in S:
    if I == "I":
        x += 1
        if max < x:
            max = x
        continue
    if I == "D":
        x -=1
        continue
print(max)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    a = int(input())
    s = input()
    count =0
    for i in s:
        if i == "I":
            count +=1
        else:
            count -=1
    print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
S=input()
x=0
for i in S:
  if i=="I":
    x+=1
  elif i=="D":
    x-=1
print(x)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(input())
count = 0
ans = []
for i in s:
    if i == 'I':
        count += 1
    elif i == 'D':
        count -= 1
    ans.append(count)
print(max(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = list(input())
count = 0
for i in s:
    if i =='I':
        count += 1
    elif i == 'D':
        count -= 1
print(count)

Submission status: Wrong Answer

Solution code:
n=int(input())
s = input()
ls = len(s)
ans = 0
for i in range(1,ls):
    ans = max(ans, s[:i].count('I')-s[:i].count('D'))
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
x = 0
i = 0
for i in range(len(s)):
  i = i + (s[i]=='I') - (s[i]=='D')
  x = max(x,i)
print(x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

a = [0]*N

x = 0

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(max(ans_lis))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(input())
B = [0]*N
C = [0]*N
for i in range(N):
  if A[i] == "I":
    B[i] = 1
  else:
    B[i] = -1
C[0] = B[0]
for i in range(1, N):
  C[i] = C[i-1]+B[i]
print(max(C))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#a,b,c,d=map(int,input().split())
n=int(input())
s=input()
ans=0
for i in s:
  if i=="I":
    ans+=1
  elif i=="D":
    ans-=1
  
if ans<0:
  print(0)
else:
  print(ans)

Submission status: Wrong Answer

Solution code:
s=input()
ans=0
k=0
for i in s:
    if i=='I':
        k+=1
        ans=max(ans,k)
    elif i=='D':
        k-=1
print(ans)

Submission status: Wrong Answer

Solution code:
input()
s = input()

m = 0
ans = 0
for q in s:
    d = 1 if q == "I" else -1
    if m < m + d:
        ans = m + d
    m = m + d

print(0 if ans < 0 else ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = input()
S = list(input())
print(max(S.count('D'), S.count('I')))

Submission status: Wrong Answer

Solution code:
N = input()
S = list(input())
print(S.count('D') + S.count('I'))

Submission status: Wrong Answer

Solution code:
#2020-04-29
x = 0
lst = [0]
n = int(input())
s = list(input())
 
for i in range(n-1):
    if s[i] == 'I':
        x += 1
        lst.append(x)
    else:
        x -= 1
        lst.append(x)
 
print(max(lst))

Submission status: Wrong Answer

Solution code:
# 2020-04-29
x = 0
lst = [0]
n = int(input())
s = list(input())

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

        print(max(lst))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import itertools

n = int(input())
s = list(input())
s1 = [1 if s[i] == 'I' else -1 for i in range(n)]
cumsum = list(itertools.accumulate(s1))
print(s1)
print(cumsum)
ans = max(cumsum)
print(max(ans, 0))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    s = list(input().split())

    ans = 0
    now = 0
    for i, i_d in enumerate(s):
        if i_d == 'I':
            now += 1
            ans = max(ans, now)
        else:
            now -= 1

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input().rstrip()
ans = 0
val = 0
for ch in s:
  if ch == "I":
    val += 1
    ans = max(ans, val)
  elif ch == "D":
    val -= 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
c,t=open(0)
a=[0]
for i in t:a+=a[-1]+1-2*(i=='D'),
print(max(a))

Submission status: Wrong Answer

Solution code:
a=[-2]
for i in open(0).read():a+=a[-1]+1-2*(i=='D'),
print(max(a))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
list1 = []
for counter in range (n):
  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))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
peak = []
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])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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[0])

Submission status: Wrong Answer

Solution code:
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(ans[0])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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)
print(max(A), 0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
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, 0)
print(m)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
print(s.count('I') - s.count('D'))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N = int(input())
    S = list(input())
    result = []
    for i, s in enumerate(S):
        result.append(S[:i].count('I') - S[:i].count('D'))
    print(max(result))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
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)
print(max(a))

Submission status: Wrong Answer

Solution code:
n=int(input())
s=input()
t=0
m=-1
for i in range(len(s)):
    if s[i]=="I":
        t+=1
    else:
        t-=1
    if m<t:
        m=t
print(m)

Submission status: Wrong Answer

Solution code:
a = input()
b = list(input())
count = 0
ans = 0
for c in a:
  if c == "I":
    count += 1
  else:
    count -= 1
  if count >= ans:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
"""
author : halo2halo
date : 31, Jan, 2020
"""

import sys
import itertools

# import numpy as np

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

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

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

    ans=max(ans, cnt)

Submission status: Wrong Answer

Solution code:
"""
author : halo2halo
date : 31, Jan, 2020
"""

import sys
import itertools

# import numpy as np

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

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

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

    ans=max(ans, cnt)

Submission status: Wrong Answer

Solution code:
"""
author : halo2halo
date : 31, Jan, 2020
"""

import sys
import itertools

# import numpy as np

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

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

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

    max(ans, cnt)

Submission status: Wrong Answer

Solution code:
"""
author : halo2halo
date : 31, Jan, 2020
"""

import sys
import itertools

# import numpy as np

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

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

print(max(0, S.count('I') - S.count('D')))

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(max(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

m = 0
for i in range(1, N):
    m = max(m, S[:i].count('I') - S[:i].count('D'))
print(m)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
S = list(input().rstrip())
maxx = -(10 ** 9)
x = 0
for i in S:
    if i == "I":
        x += 1
    else:
        x -= 1
    if x > maxx:
        maxx = x
print(x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(max_ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
num = 0
for s in S:
    if s == "I":
        num += 1
    else:
        num -= 1
print(num)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A = int(input())
S = input()
s = -1
count = 0
for i in S:
  if (s<=count)and(i == 'I'):
    count += 1
    s = count
  elif i == 'I':
    count += 1
  else:
    count += -1
print(s)

Submission status: Wrong Answer

Solution code:
A = int(input())
S = input()
s = 0
count = 0
for i in S:
  if (s<=count)and(i == 'I'):
    count += 1
    s = count
  else:
    count = -1
print(s)

Submission status: Wrong Answer

Solution code:
A = int(input())
S = input()
s = 0
count = 0
for i in S:
  if i == 'I':
    count += 1
    if s < count:
      s = count
  else:
    count = 0
print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())

x = 0
x_list = []
for si in input():
  if si == 'I':
    x = x + 1
  if si == 'D':
    x = x - 1
  x_list.append(x)

print(max(x_list))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
_ = input()
s = input()

print(max((s.count('I') - s.count('D')), 0))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
X = []
x = 0
for s in S:
  if s == 'I':
    x += 1
    X.append(x)
  else:
    x -= 1
    X.append(x)
X.sort(reverse = True)
print(X[0])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(N)
print(S)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
_=input()
s=input()
x=0
maxn=0
for i in s:
  if i == 'I':
    x+=0
  else:
    x-=0
  maxn=max(maxn,x)
print(maxn)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input().split()
X = 0

S1 = list(S[0])
S1_mod = [-1 if i == "I" else i for i in S1]
S1_mod = [1 if i == "D" else i for i in S1_mod]

l = []
for i in S1_mod:
  if i == -1:
    X += -1
    l.append(X)
  else:
    X+= 1
    l.append(X)

print(max(l))

Submission status: Wrong Answer

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