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

Solution code:
N=int(raw_input())
S=raw_input()
print max(map(lambda s : reduce(lambda x,y:x+(1 if y=="I" else -1),s,0),[S[:i]for i in range(1,len(S)+1)])+[0])

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return list(map(int, input().split()))
def II(): return int(input())
def LS(): return input().split()
def S(): return input()


def main():
    n = II()
    s = S()
    r = 0
    t = 0
    for c in s:
        if c == 'I':
            t += 1
            if r < t:
                r = t
        else:
            t -= 1
    return r


print(main())

Submission status: Accepted

Solution code:
N = int(raw_input())
S = raw_input()
x = 0
maxx = 0

for c in S:
    if c == 'I':
        x += 1
    if c == 'D':
        x -= 1
    if x > maxx:
        maxx = x

print maxx

Submission status: Accepted

Solution code:
N=map(int,input())
S=input()
ans = 0
x = 0
for c in S:
  x += {'I':+1, 'D':-1}[c]
  ans = max(ans, x)
print(ans)

Submission status: Accepted

Solution code:
x_max = 0
x = 0
input()
for c in list(input()):
    if c == "I":
        x += 1
        if x > x_max:
            x_max = x
    else:
        x -= 1
print(x_max)

Submission status: Accepted

Solution code:
x = 0;
N = int(input());
#Max value of x
M = 0;
S=input();
for i in range(N):
    if S[i] == 'I':
        x = x+1;
    else:
        x = x-1;
    M = max(M,x);
print(M);

Submission status: Accepted

Solution code:
n = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
S = input()
ans = [0] * (N+1)

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

print(max(ans))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


count = 0
MAX = 0
for i in S:
    if i == 'I':
        count += 1
    elif i == 'D':
        count -= 1
    if MAX < count:
        MAX = count

print(MAX)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

print(m)

Submission status: Accepted

Solution code:
#ARC052B

n=int(raw_input())
s=raw_input()
res_max=0
temp=0
for i in range(len(s)):
 if s[i]=='I':
  temp+=1
  res_max=max(res_max,temp)
 elif s[i]=='D':
  temp-=1
print res_max

Submission status: Accepted

Solution code:
input()
cnt = ans = 0
for c in raw_input():
    if c is "I":
        cnt += 1
    else:
        cnt -= 1
    ans = max(ans, cnt)
print ans

Submission status: Accepted

Solution code:
N = input()
S = input()
x = 0
max_x = 0
for s in S:
    if s == 'I':
        x += 1
        if x > max_x:
            max_x = x
    else:
        x -= 1
print(max_x)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
t=input()
x=0
m=0
s=raw_input()
for i in s:
	if i=='I':
		m+=1
	else:
		m-=1
	x=max(x,m)
print x

Submission status: Accepted

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

Submission status: Accepted

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

ma = 0
x = 0
for i in range(len(s)):
    if s[i] == 'I':
        x += 1
    else:
        x -= 1

    if ma < x:
        ma = x


print(ma)

Submission status: Accepted

Solution code:
input()
S = input()
x = 0
max_x = 0
for elem in S:
    if elem == "I":
        x += 1
    elif elem == "D":
        x -= 1
    if x > max_x:
        max_x = x
print(max_x)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = raw_input()

S = raw_input()

x = 0
max_x = x

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

print max_x

Submission status: Accepted

Solution code:
n = int(raw_input())
s = str(raw_input())
x = 0
xs = [x]
for si in s:
    if si == 'I': x += 1
    else: x -= 1
    xs.append(x)
print max(xs)

Submission status: Accepted

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

cnt =0
x =[0]
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: Accepted

Solution code:
#002
N = int(raw_input())
S = raw_input()
result = 0
list = [0]
for i in range(N):
    if S[i] == "I":
        result+=1
        list.append(result)
    else:
        result -=1
        list.append(result)
list.sort()
print(list[N])

Submission status: Accepted

Solution code:
import copy
N = input()
S = input()
Max = i = 0
for c in S:
    if (c == 'I'):
        i += 1
        if ( Max < i):
            Max = copy.deepcopy(i)
    else:
        i -= 1
print(str(Max))

Submission status: Accepted

Solution code:
n = map(int, raw_input().split())
s = raw_input()
x = 0
max = 0
i=0
while i<len(s):
    if s[i] == 'I':
        x = x + 1
        if max < x:
            max = x
    elif s[i] == 'D':
        x = x - 1

    i=i+1
print max

Submission status: Accepted

Solution code:
import sys

N = input()
S = input()
size = len(S)

if N != str(size):
 print("不正な入力です。")
 sys.exit()

max = 0
temp = 0

for i in range(size):
 if S[i] == "I":
  temp += 1
 elif S[i] == "D":
  temp -= 1
 else:
  print("I,D以外の文字が含まれています。")
  sys.exit()
 
 if max < temp:
  max = temp

print(max)

Submission status: Accepted

Solution code:
N = int(input())

s = list(input())

x = 0

ans = 0

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

print(ans)

Submission status: Accepted

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

print(m)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
S = input()
x, rec = 0, 0
for w in S:
    if w == "I":
        x += 1
        if x > rec:
            rec = x
    else:
        x -= 1

print(rec)

Submission status: Accepted

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

for i in s:
    if i == 'I':
        x += 1
    else:
        x -= 1
    if x > x_max:
        x_max = x

print(x_max)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

x = 0
x1 = 0


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

print(int(x1))

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

res = [0] * (n + 1)

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

#print(res)
print(max(res))

Submission status: Accepted

Solution code:
import numpy as np

a=int(raw_input())

com = raw_input()

#print a
coma = list(com)

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

#print num
#print s
print max(num)

Submission status: Accepted

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

x = 0
max_x = 0

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

print(max_x)

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
        else:
                x-=1
        M=max(x,M)

print(M)

Submission status: Accepted

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

    print(ans)

Main()

Submission status: Accepted

Solution code:
n = int(input())
s = list(input())
tmp = [0 for x in range(n+1)]
current=0
for idx, ss in enumerate(s):
    if ss=='I':
        tmp[idx+1]=tmp[current]+1
    else:
        tmp[idx+1]=tmp[current]-1
    current+=1
print(max(tmp))

Submission status: Accepted

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

def caluculate_x(n, s):
    x = 0
    x_list = [0]
    
    i = 0
    while (i < n):
        if (s[i] == 'I'):
            x += 1
        elif (s[i] == 'D'):
            x -= 1
        
        x_list.append(x)
        
        i += 1
        
    return x_list

answer = max(caluculate_x(n, s))
print(answer)

Submission status: Accepted

Solution code:
if __name__=="__main__":
    a= int(input())
    S= input().strip()
    x = 0
    m = 0
    for ch in S:
        if ch == "I":
            x += 1
        else:
            x -= 1
        m = max(m,x)
    print(m)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

n = input()
s = raw_input()
cnt = 0
max = 0

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

    if max < cnt:
        max = cnt

print max

Submission status: Accepted

Solution code:
# your code goes here
n = int(input())
s = input()

x = 0
max_x = 0

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

print(max_x)

Submission status: Accepted

Solution code:
n=raw_input()
s=raw_input()
s=list(s)
max=0
now=0

for str in s:
    if str=="I":
        now+=1
        if now>max:
            max=now
    if str=="D":
        now-=1
print max

Submission status: Accepted

Solution code:
a = input()
x = 0
s = input()
max = 0

for i in s:
  if i == 'I':
    x+=1
    if x > max:
      max = x
  elif i == 'D':
    x-=1

print(max)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

n = int(input())
S = input()

x = 0
ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
N = input()
S = raw_input()
ans,max_ = 0,0
for char in S:
    ans = ans + 1 if char is 'I' else ans - 1
    max_ = ans if max_ <= ans else max_
print max_

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(raw_input())
S = raw_input()
max = 0
x = 0
for s in S:
  if s == 'I':
    x+=1
  else:
    x-=1
  if x>max:
    max = x
print max

Submission status: Accepted

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

print(max(a) if max(a) >= 0 else 0)

Submission status: Accepted

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

Submission status: Accepted

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

print(m)

Submission status: Accepted

Solution code:
#!/usr/bin/env python

cnt = 0
hoge = [0]

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

for x in s:
    if x == 'I':
        cnt += 1
    else:
        cnt -= 1
    hoge.append(cnt)

print(max(hoge))

Submission status: Accepted

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

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

Submission status: Accepted

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

mx = 0
x = 0
for c in s:
    if c == 'I':
        x += 1
        if x > mx:
            mx = x
    else:
        x -= 1

print(mx)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
raw_input()
x = 0
ans = 0
for ch in raw_input():
    if ch == 'I':
        x += 1
    else:
        x -= 1
    ans = max(ans, x)
print ans

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
num = int(input())
given = input()
new = given.split()
x = 0
max = 0
for i in range(num):
  if new[i] == "D":
    x -= 1
  if new[i] == "I":
    x += 1
  if max < x:
    max = x
print(max)

Submission status: Runtime Error

Solution code:
num = int(input())
given = input()
new = given.split()
x = 0
max = 0
for i in range(num):
  if new[i] == "D":
    x -= 1
  elif new[i] == "I":
    x += 1
  if max < x:
    max = x
print(max)

Submission status: Runtime Error

Solution code:
N = int(input())
S = input()
a = 0
sum_a = 0

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n  =int(input())
s = input()
c = 0
t = []
t1 = []
for i in s:
	if i=='I':
		c+=1
		t.append(c)
	elif i=='D':
		c-=1
		t1.append(c)


if (max(max(t),max(t1)))<0:
	print(0)
else:
	print(max(max(t),max(t1)))

Submission status: Runtime Error

Solution code:
n  =int(input())
s = input()
c = 0
t = []
t1 = []
for i in s:
	if i=='I':
		c+=1
		t.append(c)
	elif i=='D':
		c-=1
		t1.append(c)

print(max(max(t),max(t1)))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
s = input()

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

Submission status: Runtime Error

Solution code:
 = int(input())
S = str(input())
cnt = 0

ans = []
for i in range(0,N):
  if S[i] == "I":
    cnt = cnt+1
  elif S[i] == "D":
    cnt = cnt-1
  ans.append(cnt)

if max(ans) <= 0:
  print("0")
else:
  print(max(ans))

Submission status: Runtime Error

Solution code:
def li():
    return list(map(int, input().split()))
def mi():
    return map(int, input().split())
def ii():
    return int(input())

N = ii()
S = input()

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

print(result)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())

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

Submission status: Runtime Error

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 x<0:
  print(0)
else:
  print(ans)

Submission status: Runtime Error

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 x<0:
  print(0)
else:
  print(x)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

for c in x:
  if c == "I":
    x += 1
  else:
    x -= 1
  if x > ans:
    ans = x

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input())
l=list(map(str,input().split()))
lis=[0]
count=0
for i in range(n):
  if l[i]='D':
    lis.append(count-1)
    count-=1
  else:
    lis.append(count+1)
    count+=1
print(max(lis))

Submission status: Runtime Error

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: Runtime Error

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

max = 0
x = 0

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

print(max)

Submission status: Runtime Error

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

Submission status: Runtime Error

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(ams, 0))

Submission status: Runtime Error

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

Submission status: Runtime Error

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: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

print(max(ans))

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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: Runtime Error

Solution code:
n,s=map(int,input().split())
l=[0]
for i in s:
  x= -1 if i=="D" else 1
  l+=[l[-1]+x]
print(max(l))

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
S = input()
m = 0
p = 0
for i in S:
  if i == D:
    p -= 1
  else:
    p += 1
  if p >= m:
    m = p
print(m)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

count = 0
count_list = []
for i in S:
    if i == 'I':
        count += 1
        count_list.append(count)
    elif i == 'D':
        count -= 1
    else:
        print('Error')
    
max_count = max(count_list)
if max_count > 0:
    print(max_count)
else:
    print(0)

Submission status: Runtime Error

Solution code:
#n,l = map(int,input().split())
#l = kist(input())

l = list(input())
cnt=0
ans=0

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

print(ans)

Submission status: Runtime Error

Solution code:
#n,l = map(int,input().split())
#l = kist(input())

l = kist(input())
cnt=0
ans=0

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

print(ans)

Submission status: Runtime Error

Solution code:
_ = input()
S = input()
max_n = 0
temp = 0

for s in S:
  temp += 1 if s == 'I' else temp -= 1
  if max_n < temp:
    max_n = temp
    
print(max_n)

Submission status: Runtime Error

Solution code:
n = int(input())
s = input()
x = 0
m = [0,]

def incre():
    for i in range(len(s)):
        if s[i] == 'I':
            x += 1
            m.append(x)
        elif s[i] == 'D':
            x -= 1
            m.append(x)
    else:
        print(max(m))

if __name__ == "__main__":
    incre()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

print(x)

Submission status: Runtime Error

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

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

print(x)

Submission status: Runtime Error

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

for i in range(n):
  if i == "I":
    y += 1
    x = max(x,y)
  if i == "D":
    y = y - 1

print(x)

Submission status: Runtime Error

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

for i in s:
  if i == "I":
    x += 1
    if before < x:
      before = x
  else:
    x -= 1
print(berofe)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

ans=[0]*(n+1)
for i,s in S:
  if s=="I":
    ans[i+1]=ans[i]+1
  elif s=="D":
    ans[i+1]=ans[i]-1

print(max(ans))

Submission status: Runtime Error

Solution code:
# ABC052B - Increment Decrement
def main():
    _, S = tuple(input() for _ in range(2))
    ans, x = [0], 0
    for i in S:
        x += 1 i == "I" else -1
        ans += [x]
    print(max(ans))


if __name__ == "__main__":
    main()

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
input()
s = input()

x,m = 0, 0

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

print(m)

Submission status: Runtime Error

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