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

Submission status: Wrong Answer

Solution code:
input()
temp=0
maxV=-1
for s in input():
  temp+=1 if s=="I" else -1
  if maxV<temp:maxV=temp 
print(maxV)

Submission status: Wrong Answer

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

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

print(max(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0
for i in range(len(S)):
  ans = max(ans, S[:i].count("I")-S[:i].count("D"))
print (ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A= int(raw_input())
S = list(raw_input())
x = 0
ans = [0]
for i in S:
    if i == "I":
        x += 1
    else:
        x -= 1
    ans.append(x)
    print ans
print max(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n = int(input())
s = str(input())
x = 0
tmpmax = 0
for char in s:
  if s == 'I':
    x += 1
    if x > tmpmax:
      tmpmax = x
  else:
    x -= 1
print (tmpmax)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = str(input())
iCount = s.count('I')
dCount = s.count('D')
ans = iCount - dCount + 1
if ans < 0:
    print(0)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = str(input())
iCount = s.count('I')
dCount = s.count('D')
print(iCount - dCount + 1)

Submission status: Wrong Answer

Solution code:
a = input()
maxi = 0
now = 0
for c in a:
  if c == 'I':
    now += 1
  else:
    now -= 1
  if now > maxi:
    maxi = now
print(maxi)

Submission status: Wrong Answer

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

mx = n
current = n
for c in s:
  if c == "I":
    current += 1
  elif c == "D":
    current -= 1
  if current > mx:
    mx = current


print(mx)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = input()
s = input()
x = 0
for chara in s:
  if(chara == "I"):
    x += 1
  else:
    x -=1
print(x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import time
import re
import math

def main():
    n=int(input())
    s=input()
    x=0
    mx=0
    for a in s:
        if(a=='I'):x+=1
        elif(a=='D'):x-=1

        mx=max([mx,x])

main()

Submission status: Wrong Answer

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

ans = -10000
for i in range(1,N+1):
  ans = max(S[:i].count('I')-S[:i].count('D'),ans)

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()

x = 0
max_x = 0
for i in s:
  if i == "D":
    x -= 1
  else:
    x += 1
  max_x = max(x, max_x)
print(max_x)

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
tmp = []
ans = [0]
d = 0
i = 0
flag = 0

#連続するDの個数Iの個数を交互に配列に格納
for q in range(len(s)):
    if s[q] == 'D' and flag == 0:
        d += 1
    elif s[q] == 'D' and flag == 1:
        tmp.append(i)
        i = 0
        d = 1
    elif s[q] == 'I' and flag == 0:
        tmp.append(d)
        d = 0
        i = 1
    elif s[q] == 'I' and flag == 1:
        i += 1
if i != 0:
    tmp.append(i)
elif d != 0:
    tmp.append(d)

#作成したtmpの累積和配列をつくり最大値を出力とする
for q in range(len(tmp)):
    ans.append(ans[q] + tmp[q]*(-1)^(i+1))
print(max(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
s = input()
tmp = []
ans = [0]
d = 0
i = 0
flag = 0

#連続するDの個数Iの個数を交互に配列に格納
for q in range(len(s)):
    if s[q] == 'D' and flag == 0:
        d += 1
    elif s[q] == 'D' and flag == 1:
        tmp.append(i)
        i = 0
        d = 1
    elif s[q] == 'I' and flag == 0:
        tmp.append(d)
        d = 0
        i = 1
    elif s[q] == 'I' and flag == 1:
        i += 1

#作成したtmpの累積和配列をつくり最大値を出力とする
for q in range(len(tmp)):
    ans.append(ans[q] + tmp[q]*(-1)^(i+1))
print(max(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

k=s.count("D")
m=s.count("I")

print(int(m-k))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# 入力
N=int(input())
S=input()

c=0
for x in S:
  if x=='I':
    c+=1
  elif x=='D':
    c-=1

# 出力
print(c)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
plus_ = S.count("I")
minus_ = S.count("D")
print(max(plus_-minus_,0))

Submission status: Wrong Answer

Solution code:
N = int(input())
tex=list(input())
print(tex)
max=0
cur=0
for i in range(N):
  if tex[i]=="I":
    cur+=1
    if cur>max:
      max=cur
  else:
    cur-=1
print(max)

Submission status: Wrong Answer

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

#https://atcoder.jp/contests/abc052/tasks/abc052_b

def main():
    x = 0
    N = input()
    S = raw_input()
    
    # アルゴリズムを考えるよりも、 1 <= N <= 100 であるからすべてなめたほうが早い
    x_max = x
    for ope  in S:
        x_max = max(x,x_max)
        if ope == 'I':
            x = x + 1
        elif ope == 'D':
            x = x -1

    print(x_max)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding utf-8 -*-
N=int(input())
S=list(str(input()))
ans=0

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


print(ans+1)

Submission status: Wrong Answer

Solution code:
n=int(input())
max_x=-100
x=0
for i in input():
	if 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())
cnt = 0
ch = 0
*w, = map(str,input().split())
for i in w:
  if i == 'I':
    cnt+=1
  else:
    cnt-=1
  if cnt > ch:
    ch = cnt
print(ch)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

add = 0
x = []

for i in S:
    if i == 'D':
        x.append(0)
    elif i == 'I':
        add += 1
        x.append(add)
    else:
        add -= 1
        x.append(add)
print(max(x))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
S = input()

I_count = [i for i, x in enumerate(S) if x == 'I']
D_count = [i for i, x in enumerate(S) if x == 'D']

tmp = [0] * N
for i in I_count:
    tmp[i] = 1
for i in D_count:
    tmp[i] = -1

ans = 0
List = []
for i in range(N):
    ans += tmp[i]
    List.append(ans)
    
print(max(0, ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
input();s=input();print(max(i-2*s[:i].count('D')for i in range(len(s))))

Submission status: Wrong Answer

Solution code:
input();s=input();print(max(i-2*s[:i].count('D')for i in range(99)))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(input())
t=0
ans=-105
for i in A:
  if i=="D":
    t-=1
    ans=max(ans,t)
  else:
    t+=1
    ans=max (ans,t)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
input()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = input()
n = int(n)
str = input()
val = []
x = 0
for _ in range(n):
  o = str[:1]
  if o == 'D':
    x -= 1
  else:
    x += 1
  val.append(x)
  str = str[1:]
print(max(val))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(max(temp))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = str(input())
lst_for_ans = []
if S.count("D") > S.count("I"):
    print(0)
else:
    for i in range(len(S)):
       I_count = S[:i].count("I")
       D_count = S[:i].count("D")
       lst_for_ans.append(I_count - D_count)

       print(max(lst_for_ans))

Submission status: Wrong Answer

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

print(max(lst_for_ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

A = []

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

print(max(A))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
S = str(input())
a = []
for i in range(N):
  b = S[0:i+1].count("I")
  c = S[0:i+1].count("D")
  M = b-c
  a.append(M)
print(max(a))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
S = str(input())
a = []
for i in range(N):
  b = S[:i].count("I")
  c = S[:i].count("D")
  M = b-c
  a.append(M)
print(max(a))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
S = str(input())
a = []
for i in range(N):
  b = S[:i+1].count("I")
  c = S[:i+1].count("D")
  M = b-c
  a.append(M)
print(max(a))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
S = str(input())
a = []
for i in range(N):
  a.append(S[:i])
  b = S[:i].count("I")
  c = S[:i].count("D")
  M = b-c
print(max(a))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
input()
x = 0
for a in input():
  x += int(a.replace('I','1').replace('D','-1'))

print(max([0,x]))

Submission status: Wrong Answer

Solution code:
input()
tmp = x = 0
for c in input():
  x += int(c.replace('D','-1').replace('I','1'))
  if x > 0:
    tmp = x
print(tmp)

Submission status: Wrong Answer

Solution code:
input()
a = input()
x = 0
for b in a:
  x += int(b.replace('I','1').replace('D','-1'))
print(x) if x >= 0 else print(0)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input()
x = 0
for b in a:
  x += int(b.replace('I','1').replace('D','-1'))
print(x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# this is cumulative
n = int(input())
s = input()

point = 0
cum_sum = []

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

X = []
x = 0

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

print(max(X))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

x = 0

a = list(S)

I_count = 0
D_count = 0

cnt_I = a.count("I")
cnt_D = a.count("D")

for i in a:
    if cnt_I - I_count < cnt_D - D_count:
        break
    else:
        if i == "I":
            I_count += 1
        else:
            D_count += 1
        

print(I_count - D_count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#52b
n = int(input())
s = input()
ans = []
temp = 0

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

print(max(ans))

Submission status: Wrong Answer

Solution code:
#52b
n = int(input())
s = input()
ans = [0]

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

print(max(ans))

Submission status: Wrong Answer

Solution code:
#52b
n = int(input())
s = input()
ans = []
temp = 0

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

print(ans.index((max(ans))))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

li = list(s)

x = 0
num_list = list()
for argv in li:
	if argv == "I":
		x += 1
		num_list.append(x)
	elif argv == "D":
		x -= 1
		num_list.append(x)


print(max(num_list))

Submission status: Wrong Answer

Solution code:

n = input()
s = input()

li = list(s)

x = 0
for argv in li:
	if argv == "I":
		x += 1
	elif argv == "D":
		x -= 1

print(x)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
s = np.array(list(input()))
s = (s == "I") * 2 - 1
print(s.cumsum().max())

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
S = raw_input()
x = 0
ma = 0
for s in S:
  x += 1 if s=="I" else 0
  ma = max(ma, x)
print ma

Submission status: Wrong Answer

Solution code:
i = int(input())
s = input()
ans = 0

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

print(ans)

Submission status: Wrong Answer

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

s_c = s.count("D")

print(i - s_c)

Submission status: Wrong Answer

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

s_c = s.count("I")

print(i - s_c)

Submission status: Wrong Answer

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

for i in S:
    if i == "I":
        count += 1
else:
    print(count)

Submission status: Wrong Answer

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

for i in range(N):
    if i == "I":
        count += 1
else:
    print(count)

Submission status: Wrong Answer

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

for i in range(N):
    if i == "I":
        count += 1
    if i == "D":
        count -= 1
else:
    print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(n):
    d = s[i:].count("D")
    if d > len(s[i:]) - d:
        break
    if i == n-1:
        i = n
    
print(2 * s[:i].count("I") - len(s[:i]))

Submission status: Wrong Answer

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

for i in range(n):
    d = s[i:].count("D")
    if d > len(s[i:]) - d:
        break
        
print(2 * s[:i].count("I") - len(s[:i]))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
inputted = int(raw_input())
l = list(raw_input())
x = 0
record = []
for i in range(len(l)):
    record.append(x)
    if l[i] == "I":
        x+=1

    elif l[i] == "D":
        x-=1

print max(record)

Submission status: Wrong Answer

Solution code:
#codinf:utf-8
x = 0
s = int(input())
n = input()
n_list = list(n)
resalt = []

for i in range(s):
	if n_list[i]=="I":
		x += 1
		resalt.append(x)
	elif n_list[i]=="D":
		x -=1
		resalt.append(x)

max_resalt = max(n_list)
print(max_resalt)

Submission status: Wrong Answer

Solution code:
d = {"I": 1, "D": -1}
x = 0
N = int(input())
S = input()
ans = -1000
for Si in S:
    x += d[Si]
    ans = max(ans, x)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
state = [0]
for c in list(input()):
  if c == "D":
    a = state[-1]
    a -= 1
  else:
    a = state[-1]
    a += 1
  state.append(a)
print(max(state))

Submission status: Wrong Answer

Solution code:
#coding: shift_jis


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

Submission status: Wrong Answer

Solution code:
n = input()
a = list(input())


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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
S = input()
x = 0
ans = 0
for l in S:
	if l == "I":
		x += 1
	elif l == "D":
		x -= 1
	ans = max(ans,x)

Submission status: Wrong Answer

Solution code:
input()
n=input()
a=c=0
for i in n:
  if i=='I':a+=1
  else:a-=1
  c=max(a,c)
print(a)

Submission status: Wrong Answer

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

ma = 0
x = 0
for i in range(len(s)):
    if ma < x:
        ma = x

    if s[i] == 'I':
        x += 1
    else:
        x -= 1

print(ma)

Submission status: Wrong Answer

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

cnt =0
x =[]
for i in xrange(n):
    if s[i] == 'I':
        cnt += 1
        x.append(cnt)
    elif s[i]  == 'D':
        cnt -= 1
        x.append(cnt)

print max(x)

Submission status: Wrong Answer

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

cnt =0
x =[]
for i in xrange(n):
    if s[i] == 'I':
        cnt += 1
        x.append(cnt)
    elif s[i]  == 'D':
        cnt -= 1
        x.append(cnt)
    else:
        x.append(cnt)

print max(x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(raw_input())
s = raw_input()
x = []
cnt = 0
for i in xrange(n):
    if s[i] == 'I':
        cnt += 1
        x.append(cnt)
    elif s[i] == 'D':
        cnt -= 1
        x.append(cnt)
    else:
        x.append(cnt)
print max(0,x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

_ = input()
st = input().strip()
total = 0
result = []

for i in st:
    if (i == 'I'):
        total += 1
        result.append(total)
    else:
        total -= 1
        result.append(total)
print (max(result))

Submission status: Wrong Answer

Solution code:
maxi = 0
x = 0
s = input()
for c in s:
    if c is 'I':
        x = x + 1
        if x > maxi:
            maxi = x
    else:
        x = x - 1
print(maxi)

Submission status: Wrong Answer

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = input()
x = 0
res = 0

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

print(res)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

print(max(l))