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-----
5
IIDID

-----Sample Output-----
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.

Difficulty: EASY

Solutions:
n = int(input())
s = list(input())
max = x = 0
for i in s:
	if i == 'I':
		x += 1
	else:
		x -= 1
	if max < x:
		max = x
print(max)


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


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


N = int(input())
S = input()
t = m = 0
for s in S:
	t += 1 if s == 'I' else -1
	if t > m:
		m = t
print(m)


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


input()
s = t = 0
for c in input():
	if c == 'I':
		t += 1
	if c == 'D':
		t -= 1
	s = max(s, t)
print(s)


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


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


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


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


N = int(input())
S = input()
Sum = 0
Max = 0
for s in S:
	Sum += (-1) ** (s == 'D')
	Max = max(Sum, Max)
print(Max)


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


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


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 + d[i]
print(max(d))


n = int(input())
s = input()
c = 0
m = 0
for i in s:
	if i == 'I':
		c += 1
	else:
		c -= 1
	m = max(m, c)
print(m)


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


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


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


n = int(input())
s = list(input())
a = [0] * (n + 1)
for i in range(n):
	a[i + 1] = a[i] + [1, -1][s[i] == 'D']
print(max(a))


n = int(input())
s = input()
m = 0
x = 0
for w in s:
	if w == 'I':
		x += 1
	else:
		x -= 1
	if x > m:
		m = x
print(m)


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


(a, b) = (int(input()), input())
(j, l) = (0, [0])
for i in b:
	if i == 'I':
		j += 1
	else:
		j -= 1
	l.append(j)
print(max(l))


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


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


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


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


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


from itertools import accumulate as ac
n = int(input())
s = [1 if i == 'I' else -1 for i in input()]
print(max(ac([0] + s)))


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


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)


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


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


num = input()
count = 0
max = 0
message = input()
table = list(message)
for i in table:
	if i == 'I':
		count += 1
	elif i == 'D':
		count -= 1
	if max <= count:
		max = count
print(max)


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


input()
x = 0
li = [0]
for c in input():
	x += (c == 'I') - (c == 'D')
	li += [x]
print(max(li))


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


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


a = int(input())
b = input()
c = 0
d = 0
for i in range(a):
	if b[i] == 'D':
		c = c - 1
	if b[i] == 'I':
		c = c + 1
	if c > d:
		d = c
print(d)


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


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


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


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


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


input()
S = input()
cnt = 0
maxN = 0
for i in S:
	cnt += 1 if i == 'I' else -1
	maxN = max(maxN, cnt)
print(maxN)


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


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


input()
s = input()
while 'DI' in s:
	s = s.replace('DI', '')
print(s.count('I'))


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


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


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


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


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


n = int(input())
s = input()
num_list = [0]
sum = 0
for w in s:
	if w == 'I':
		sum += 1
	else:
		sum -= 1
	num_list.append(sum)
num_list.sort()
ans = num_list[-1]
print(ans)


n = int(input())
s = input()
x = ans = 0
for c in s:
	x += [-1, 1][c == 'I']
	ans += (ans < x) + 0
print(ans)


n = int(input())
s = input()
maxv = 0
v = 0
for c in s:
	if c == 'I':
		v += 1
	else:
		v -= 1
	maxv = max(maxv, v)
print(maxv)


(_, t) = open(0)
a = b = 0
for x in t:
	b += x > 'D' or -1
	a = max(a, b)
print(a)


n = int(input())
ans = 0
tmp = 0
for i in input():
	if i == 'I':
		tmp += 1
	else:
		tmp -= 1
	if tmp > ans:
		ans = tmp
print(ans)


N = int(input())
S = list(input())
x = 0
maxi = 0
for i in S:
	if i == 'I':
		x += 1
	else:
		x -= 1
	if x > maxi:
		maxi = x
print(maxi)


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


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


N = int(input())
A = [0]
for s in input():
	if s == 'I':
		A.append(A[-1] + 1)
	else:
		A.append(A[-1] - 1)
print(max(A))


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


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


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

def ans052(N: int, S: str):
	x = 0
	x_list = [0]
	for i in range(N):
		if S[i] == 'I':
			x += 1
			x_list.append(x)
		elif S[i] == 'D':
			x -= 1
			x_list.append(x)
	x_list.sort()
	return x_list[-1]
print(ans052(N, S))


x = [0]
input()
l = input()
for i in l:
	if i == 'I':
		x.append(x[-1] + 1)
	else:
		x.append(x[-1] - 1)
print(max(x))


import sys
input = sys.stdin.readline

def main():
	answers = [0]
	n = int(input())
	S = input()
	x = 0
	for s in S:
		if 'I' in s:
			x += 1
			answers.append(x)
		elif 'D' in s:
			x -= 1
			answers.append(x)
	print(max(answers))

def __starting_point():
	main()
__starting_point()


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


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


input()
g = m = 0
dic = {'I': 1, 'D': -1}
for s in input():
	g += dic[s]
	m = max(m, g)
print(m)


n = int(input())
s = input().rstrip()
res = 0
x = 0
for c in s:
	x += 1 if c == 'I' else -1
	res = max(res, x)
print(res)


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


(N, S) = (input(), input())
(x, xmax) = (0, 0)
for s in S:
	x = (lambda a: x + 1 if a == 'I' else x - 1)(s)
	xmax = max(x, xmax)
print(xmax)


input()
x = [0]
for c in input():
	x.append(x[-1] + 2 * (c == 'I') - 1)
print(max(x))


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


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


n = int(input())
s = input()
x = 0
res = 0
for ss in s:
	if ss == 'I':
		x += 1
	else:
		x -= 1
	res = max(res, x)
print(res)


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


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


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


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


N = int(input())
S = str(input())
M = 0
Sum = 0
for x in S:
	if x == 'I':
		Sum += 1
	else:
		Sum -= 1
	M = max(M, Sum)
print(M)


(n, s) = open(0)
print(max((s[:i].count('I') * 2 - i for i in range(int(n) + 1))))


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


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


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


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


input()
s = input()
m = 0
c = 0
for k in s:
	if k == 'I':
		c += 1
	else:
		c -= 1
	if c >= m:
		m = c
print(m)


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


N = int(input())
S = input()
x = 0
max_val = 0
for s in S:
	x += {'I': +1, 'D': -1}[s]
	max_val = max(max_val, x)
print(max_val)


N = int(input())
S = list(input())
counter = 0
li = [0]
for i in range(N):
	if S[i] == 'I':
		counter += 1
	else:
		counter -= 1
	li.append(counter)
print(max(li))


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


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


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


N = int(input())
S = input()
x = 0
ans = 0
for i in S:
	if i == 'I':
		x += 1
	elif i == 'D':
		x -= 1
	ans = max(ans, x)
print(ans)


N = int(input())
S = input()
x = 0
x_max = x
for c in S:
	if c == 'I':
		x += 1
		if x > x_max:
			x_max = x
	elif c == 'D':
		x -= 1
print(x_max)


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


n = int(input())
s = list(input())
a = 0
m = 0
for i in s:
	if i == 'I':
		a += 1
	else:
		a -= 1
	if a > m:
		m = a
print(m)


n = int(input())
s = input()
x = 0
m = 0
for o in s:
	x += 1 if o == 'I' else -1
	m = max(x, m)
print(m)


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


N = int(input())
S = input()
a = []
total = 0
for i in range(len(S)):
	if S[i] == 'I':
		total += 1
		a.append(total)
	else:
		total -= 1
		a.append(total)
print(max(max(a), 0))


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


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


from itertools import accumulate
input()
print(max([0] + list(accumulate([1 if s == 'I' else -1 for s in input()]))))


N = int(input())
S = input()
ans = 0
max = 0
for s in S:
	if s == 'I':
		ans += 1
	else:
		ans -= 1
	if max < ans:
		max = ans
print(max)


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


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


(n, s) = (int(input()), str(input()))
l = [0]
for i in s:
	x = -1 if i == 'D' else 1
	l += [l[-1] + x]
print(max(l))


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


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


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


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


N = input()
S = list(input())
i = 0
j = 0
for s in S:
	j += 1 if s == 'I' else -1
	i = max(i, j)
print(i)


N = int(input())
S = str(input())
ans = 0
count = 0
for i in S:
	if i == 'I':
		count += 1
	elif i == 'D':
		count -= 1
	ans = max(ans, count)
print(ans)


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


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


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


(n, s) = open(0).readlines()
ans = 0
now = 0
for i in list(s):
	if i == 'I':
		now += 2
	now -= 1
	ans = max(ans, now)
print(ans)


n = int(input())
a = list(input())
xlist = [0]
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))


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


x = int(input())
s = input()
li = [0]
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))


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


N = int(input())
S = input()
res = 0
tmp = 0
for s in S:
	if s == 'I':
		tmp += 1
	elif s == 'D':
		tmp -= 1
	res = max(res, tmp)
print(res)


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


a = int(input())
b = input()
c = 0
d = [0]
for i in b:
	if i == 'I':
		c += 1
		d.append(c)
	elif i == 'D':
		c -= 1
		d.append(c)
print(max(d))


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


import sys, math
from itertools import combinations as c, product as p
from collections import deque
sys.setrecursionlimit(10 ** 9)

def si():
	return input()

def ii():
	return int(input())

def fi():
	return float(input())

def lstr():
	return input().split()

def lint():
	return list(map(int, input().split()))

def lint_dec():
	return list(map(lambda x: int(x) - 1, input().split()))

def lnstr(n):
	return [input() for _ in range(n)]

def lnint(n):
	return [int(input()) for _ in range(n)]

def lint_list(n):
	return [lint() for _ in range(n)]
N = ii()
S = si()
x = 0
ans = 0
for s in S:
	if s == 'I':
		x += 1
	else:
		x -= 1
	ans = max(x, ans)
print(ans)


n = int(input())
s = input()
max = 0
sum = 0
for i in s:
	if i == 'I':
		sum += 1
		if max < sum:
			max = sum
	else:
		sum -= 1
print(max)


N = int(input())
S = input()
MAX = 0
x = 0
for i in S:
	if i == 'I':
		x += 1
	if i == 'D':
		x -= 1
	MAX = max(MAX, x)
print(MAX)


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)


n = int(input())
s = list(input())
x = 0
mx = 0
for a in s:
	if a == 'I':
		x += 1
	else:
		x -= 1
	if x > mx:
		mx = x
print(mx)


n = int(input())
s = str(input())
max_result = 0
result = 0
for i in s:
	if i == 'I':
		result += 1
		if result > max_result:
			max_result = result
	else:
		result -= 1
print(max_result)


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


input()
a = [0]
for x in input():
	a += [a[-1] + (x > 'D' or -1)]
print(max(a))


import sys
import copy
import math
import itertools
import numpy as np
N = int(input())
S = input()
x = 0
max = 0
for i in range(N):
	if S[i] == 'I':
		x += 1
	elif S[i] == 'D':
		x -= 1
	if max < x:
		max = x
print(max)


n = int(input())
s = list(map(str, input()))
mx = 0
sm = 0
for char in s:
	if char == 'I':
		sm += 1
		mx = max(mx, sm)
	elif char == 'D':
		sm -= 1
	else:
		continue
print(mx)


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


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


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


s = input()
t = [1 if i == 'I' else -1 for i in list(input())]
(ans, x) = ([0], 0)
for r in t:
	x += r
	ans.append(x)
print(max(ans))


input()
s = input()
(x, a) = (0, 0)
for l in s:
	x += -1 + 2 * (l == 'I')
	a = max(a, x)
print(a)


def answer(n: int, s: str) -> int:
	while 'DI' in s:
		s = s.replace('DI', '')
	return s.count('I')

def main():
	n = int(input())
	s = input()
	print(answer(n, s))

def __starting_point():
	main()
__starting_point()


n = int(input())
s = input()
d = 0
m = 0
for i in s:
	if i == 'D':
		d -= 1
	else:
		d += 1
	m = max(m, d)
print(m)


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


n = int(input())
s = str(input())
x = 0
a = 0
for i in s:
	if i == 'I':
		x += 1
		if x > a:
			a = x
	else:
		x -= 1
print(a)


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


n = int(input())
s = input()
(max_n, g) = (0, 0)
for i in s:
	g = g + 1 if i == 'I' else g - 1
	max_n = max(max_n, g)
print(max_n)


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


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


def main():
	input()
	s = input()
	tmp = 0
	ans = 0
	for v in s:
		if v == 'I':
			tmp += 1
		else:
			tmp -= 1
		ans = max(ans, tmp)
	print(ans)

def __starting_point():
	main()
__starting_point()


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


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


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


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


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


input()
s = input()
while s.find('DI') > -1:
	s = s.replace('DI', '')
print(len(s.strip('D')))


cnt = int(input())
string = input()
x = [0]
i = 0
for _ in string:
	if _ == 'I':
		i += 1
		x.append(i)
	else:
		i -= 1
		x.append(i)
print(max(x))


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