Vasya has a pile, that consists of some number of stones. $n$ times he either took one stone from the pile or added one stone to the pile. The pile was non-empty before each operation of taking one stone from the pile.

You are given $n$ operations which Vasya has made. Find the minimal possible number of stones that can be in the pile after making these operations.


-----Input-----

The first line contains one positive integer $n$ — the number of operations, that have been made by Vasya ($1 \leq n \leq 100$).

The next line contains the string $s$, consisting of $n$ symbols, equal to "-" (without quotes) or "+" (without quotes). If Vasya took the stone on $i$-th operation, $s_i$ is equal to "-" (without quotes), if added, $s_i$ is equal to "+" (without quotes).


-----Output-----

Print one integer — the minimal possible number of stones that can be in the pile after these $n$ operations.


-----Examples-----
Input
3
---

Output
0
Input
4
++++

Output
4
Input
2
-+

Output
1
Input
5
++-++

Output
3


-----Note-----

In the first test, if Vasya had $3$ stones in the pile at the beginning, after making operations the number of stones will be equal to $0$. It is impossible to have less number of piles, so the answer is $0$. Please notice, that the number of stones at the beginning can't be less, than $3$, because in this case, Vasya won't be able to take a stone on some operation (the pile will be empty).

In the second test, if Vasya had $0$ stones in the pile at the beginning, after making operations the number of stones will be equal to $4$. It is impossible to have less number of piles because after making $4$ operations the number of stones in the pile increases on $4$ stones. So, the answer is $4$.

In the third test, if Vasya had $1$ stone in the pile at the beginning, after making operations the number of stones will be equal to $1$. It can be proved, that it is impossible to have less number of stones after making the operations.

In the fourth test, if Vasya had $0$ stones in the pile at the beginning, after making operations the number of stones will be equal to $3$.

Difficulty: EASY
Tags: Mathematics

Implementation
Expected Time Complexity: O(N)

Starter code:

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


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


input()
c = 0
for b in input():
	if b == '+':
		c += 1
	elif c > 0 and b == '-':
		c -= 1
print(c)


n = int(input())
s = input()
l = []
for i in range(n):
	if len(l) > 0 and s[i] == '-':
		l.pop(-1)
	elif s[i] == '+':
		l.append('+')
print(len(l))


import math, itertools, fractions, heapq, collections, bisect, sys, queue, copy
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def LS():
	return sys.stdin.readline().split()

def S():
	return input()

def main():
	n = I()
	a = 0
	s = S()
	saitei = 0
	for x in s:
		if x == '+':
			a += 1
		else:
			a -= 1
		saitei = min(saitei, a)
	b = abs(saitei)
	for x in s:
		if x == '+':
			b += 1
		else:
			b -= 1
	return b
print(main())


n = int(input())
s = input()
start = 0
pedra = 0
lista = s.split('-')
for k in range(len(lista)):
	if k == len(lista) - 1 and lista[k] == '':
		break
	pedra += len(lista[k])
	pedra -= 1
	if pedra < -start:
		start = -pedra
val = s.count('+') - s.count('-')
print(start + val)


n = int(input())
s = input()
stones = 0
if s[0] == '+':
	stones += 1
for i in range(n - 1):
	if s[i + 1] == '-' and stones == 0:
		continue
	elif s[i + 1] == '-':
		stones -= 1
	elif s[i + 1] == '+':
		stones += 1
print(stones)


def stones(n, l):
	c = 0
	for (i, item) in enumerate(l):
		if item == '+':
			c += 1
		elif c != 0:
			c -= 1
	print(c)
n = int(input())
l = input()
stones(n, l)


(n, t) = (int(input()), 0)
for c in input():
	if c == '+':
		t += 1
	elif t != 0:
		t -= 1
print(t)


n = int(input())
r = 0
for v in input().strip():
	if v == '-':
		r = max(r - 1, 0)
	elif v == '+':
		r += 1
print(r)


def cm(s, c):
	for i in range(len(s)):
		if s[i] == c:
			return i
	return -1
n = int(input())
s = input()
sum = 0
stones = 0
index = cm(s, '+')
if index == -1:
	print(0)
else:
	for i in range(index, len(s)):
		if s[i] == '+':
			stones += 1
		elif stones > 0:
			stones -= 1
	print(stones)


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


N = int(input())
s = input()
ls = []
for i in range(101):
	for j in s:
		if j == '-':
			i -= 1
			if i < 0:
				break
		else:
			i += 1
	else:
		ls.append(i)
print(min(ls))


n = int(input())
str1 = input()
m = 0
for i in str1:
	if i == '+':
		m += 1
	elif m > 0:
		m -= 1
print(m)


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


s = input()
n = input()
cur_h = 0
min_h = 0
for c in n:
	if c == '+':
		cur_h += 1
	else:
		cur_h -= 1
	min_h = min(min_h, cur_h)
print(cur_h - min_h)


input()
s = input()
cnt = 0
for c in s:
	if c == '+':
		cnt += 1
	else:
		cnt -= 1
		if cnt < 0:
			cnt = 0
print(cnt)


n = int(input())
s = input()
z = 0
for i in s:
	if i == '-':
		z -= 1
		if z == -1:
			z += 1
	else:
		z += 1
print(z)


n = int(input())
s = input()
val = 0
for i in s:
	if i == '-' and val != 0:
		val = val - 1
	if i == '+':
		val = val + 1
		continue
print(val)


n = int(input())
s = input()
cnt = 0
for ch in s:
	if ch == '-':
		cnt -= 1
	if ch == '+':
		cnt += 1
	if cnt < 0:
		cnt = 0
print(cnt)


numStones = 0
num = input()
s = input()
for i in range(len(s)):
	if s[i] == '+':
		numStones += 1
	elif numStones != 0:
		numStones -= 1
print(numStones)


def get_input() -> str:
	input()
	operatinos = input()
	return operatinos

def is_enough_stones(stones: int, operations: str) -> bool:
	for operation in operations:
		if operation == '+':
			stones += 1
		else:
			stones -= 1
		if stones < 0:
			return False
	return True

def main():
	operations = get_input()
	for i in range(101):
		stones = i
		if is_enough_stones(i, operations):
			break
	for operation in operations:
		if operation == '+':
			stones += 1
		else:
			stones -= 1
	print(stones)
main()


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


n = int(input())
a = str(input())
m = 0
l = len(a)
for i in range(l):
	if a[i] == '-' and m != 0:
		m = m - 1
	elif a[i] == '+':
		m = m + 1
print(m)


n = int(input())
flag = True
count = 0
mini = 0
for item in input():
	if item == '-':
		count -= 1
		if count < mini:
			mini = count
	else:
		count += 1
print(count + abs(mini))


n = int(input())
s = input()
ans = 0
for i in s:
	if i == '+':
		ans += 1
	elif ans == 0:
		continue
	else:
		ans -= 1
print(ans)


from collections import *
from math import *
n = int(input())
a = list(input())
k = 0
ans = 0
for i in range(n):
	if a[i] == '-':
		ans -= 1
	else:
		ans += 1
	k = min(k, ans)
print(ans - k)


n = int(input())
z = input()
q = 0
qmin = 0
for x in z:
	if x == '-':
		q -= 1
		if qmin > q:
			qmin = q
	elif x == '+':
		q += 1
print(abs(qmin) + q)


q = 1
for _ in range(q):
	n = int(input())
	s = input()
	ans = 0
	for i in range(n):
		if s[i] == '-' and ans > 0:
			ans -= 1
		elif s[i] == '+':
			ans += 1
	print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
s = input()
ans = 0
for i in range(n):
	if s[i] == '-':
		ans -= 1
	else:
		ans += 1
	if ans < 0:
		ans = 0
print(ans)


n = int(input())
s = input('')
pos = True
neg = True
n1 = 1000
m = 1000
for r in s:
	if r == '-':
		n1 -= 1
	if r == '+':
		n1 += 1
	m = min(n1, m)
print(n1 - m)


n = int(input())
s = input()
k = 0
for i in range(n):
	if s[i] == '-' and k != 0:
		k -= 1
	elif s[i] == '+':
		k += 1
print(k)


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


numberOfoperations = int(input())
operations = input()
stones = 0
for i in range(numberOfoperations):
	if operations[i] == '-':
		stones -= 1
		if stones < 0:
			stones = 0
	elif operations[i] == '+':
		stones += 1
print(stones)


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


n = int(input())
operations = input()
min_init = 0
min_stones = 0
for operation in operations:
	if operation == '+':
		min_init += 1
	else:
		min_init -= 1
	if min_init < 0:
		min_init = 0
print(min_init)


t = int(input())
str = input()
cnt = 0
for i in range(len(str)):
	if str[i] == '+':
		cnt += 1
	else:
		cnt -= 1
		if cnt <= 0:
			cnt = 0
print(cnt)


input()
st = input()
ans = 0
for c in st:
	if c == '-':
		if ans:
			ans -= 1
	else:
		ans += 1
print(ans)


N = int(input())
L = list(input())
count = 0
for i in L:
	if i == '-':
		if count == 0:
			count += 1
		count -= 1
	else:
		count += 1
print(count)


n = int(input())
b = input()
a = []
a[:0] = b
c = 0
for i in range(len(a)):
	if a[i] == '-':
		c = c - 1
	else:
		c = c + 1
	if c < 0:
		c = 0
print(c)


n = int(input())
s = input()
nr = 0
for x in s:
	if x == '+':
		nr += 1
	else:
		nr -= 1
		if nr < 0:
			nr = 0
print(nr)


n = int(input())
s = str(input())
sum = 0
l = len(s)
for i in range(0, l, 1):
	if s[i] == '+':
		sum += 1
	else:
		sum -= 1
		if sum < 0:
			sum = 0
print(sum)


input()
s = str(input())
counter = 0
for i in s:
	if i == '+':
		counter += 1
	elif i == '-' and counter > 0:
		counter -= 1
print(counter)


n = int(input())
x = 0
str1 = input()
for i in range(n):
	if str1[i] == '-':
		x = x - 1
	else:
		x = x + 1
	if x < 0:
		x = 0
print(x)


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


n = int(input())
pile = 0
s = str(input())
for i in s:
	if i == '-':
		if pile != 0:
			pile -= 1
	else:
		pile += 1
print(pile)


n = int(input())
s = str(input())
l = []
l[:0] = s
i = 0
c = 0
d = 0
n = 0
for x in l:
	if x == '-':
		c = c + 1
	else:
		d = d + 1
if c == len(l):
	print('0')
elif d == len(l):
	print(d)
else:
	for x in l:
		if x == '+':
			n = n + 1
		elif n > 0:
			n = n - 1
	print(n)


n = int(input())
s = input()
flag = False
ans = 0
for i in s:
	if i == '+':
		flag = True
		ans += 1
	elif i == '-' and flag and (ans > 0):
		ans -= 1
print(max(0, ans))


n = int(input())
s = input()
minn = 1
cur = 0
for i in s:
	if i == '-':
		cur -= 1
		if cur < minn:
			minn = cur
	else:
		cur += 1
if minn < 0:
	print(cur + abs(minn))
else:
	print(cur)


import sys
import math

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def minput():
	return map(int, sys.stdin.readline().strip().split())

def listinput():
	return list(map(int, sys.stdin.readline().strip().split()))
n = iinput()
stones = 0
s = input()
for i in s:
	if i == '-':
		if stones != 0:
			stones -= 1
	else:
		stones += 1
print(stones)


n = int(input())
di = {'+': 1, '-': 0}
l = [di[x] for x in input()]
tmp = 0
was = 0
for i in l:
	if i:
		tmp += 1
	elif tmp != 0:
		tmp -= 1
print(tmp)


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


stones = 0
n = int(input())
opr = input()
for i in opr:
	if i == '-' and stones == 0:
		continue
	elif i == '+':
		stones += 1
	else:
		stones -= 1
print(stones)


(n, a, counter) = (int(input()), list(input()), 0)
while len(a) != 0 and a[0] == '-':
	del a[0]
for i in a:
	if i == '+':
		counter += 1
	if i == '-':
		counter = max(counter - 1, 0)
print(counter)


n = int(input())
s = list(input())
count_ = 0
min_ = 0
for i in range(0, n):
	count_ += (s[i] == '+') - (s[i] == '-')
	if min_ < count_:
		max_ = min_
	else:
		min_ = count_
print(count_ - min_)


import atexit
import io
import sys
_I_B = sys.stdin.read().splitlines()
input = iter(_I_B).__next__
_O_B = io.StringIO()
sys.stdout = _O_B

@atexit.register
def write():
	sys.__stdout__.write(_O_B.getvalue())

def main():
	n = int(input())
	s = input()
	m = 0
	cp = 0
	for i in s:
		if i == '-':
			cp -= 1
		else:
			cp += 1
		if cp < 0:
			m = max(abs(cp), m)
	print(cp + m)
main()


n = int(input())
s = input()
t = 0
mn = 0
for i in s:
	if i == '-':
		t -= 1
	else:
		t += 1
	mn = min(mn, t)
print(-mn + t)


cnt = int(0)
val = int(input())
str = input()
for i in range(0, val):
	if str[i] == '-':
		cnt = cnt - 1
	else:
		cnt = cnt + 1
	if cnt < 0:
		cnt = 0
print(cnt)


n = int(input())
a = []
s = input()
b = 0
for i in s:
	if i == '+':
		b += 1
	else:
		b -= 1
	a.append(b)
min1 = min(a)
if min1 > -1:
	d = 0
else:
	d = -min1
print(d + b)


n = int(input())
s = input()
sum1 = 0
for i in s:
	sum1 += i == '+'
	if sum1 > 0:
		sum1 -= i == '-'
print(sum1)


def rocks(s):
	(count1, count2) = (0, 0)
	for elem in s:
		if elem == '-':
			count1 -= 1
		else:
			count1 += 1
		if count1 < count2:
			count2 = count1
	return count1 - count2
n = int(input())
t = input()
print(rocks(t))


a = 0
n = int(input())
s = input()[:n]
for i in s:
	if i == '-':
		a = a - 1
		if a < 0:
			a = 0
	elif i == '+':
		a = a + 1
print(a)


n = int(input())
s = input()
c = 0
if s.count('+') == 0:
	print(0)
else:
	for x in range(s.index('+'), n):
		if s[x] == '+':
			c += 1
		elif c > 0:
			c -= 1
	print(c)


n = int(input())
S = input()
if '+' not in S:
	print(0)
else:
	ans = 0
	for i in range(S.index('+'), len(S)):
		if S[i] == '+':
			ans += 1
		elif ans > 0:
			ans -= 1
	print(ans)


n = int(input())
s = [e for e in input()]
dict = {'+': s.count('+'), '-': s.count('-')}
menor_global = 0
aux = 0
for e in s:
	if e == '-':
		aux -= 1
		if aux < menor_global:
			menor_global = aux
	if e == '+':
		aux += 1
geral = -menor_global
for e in s:
	if e == '-':
		geral -= 1
	if e == '+':
		geral += 1
print(geral)


n = int(input())
a = list(input())
blah = 0
mini = []
temp = 0
for i in range(n):
	if a[i] == '-':
		temp -= 1
		mini.append(temp)
	else:
		temp += 1
		mini.append(temp)
req = min(mini)
t = -1 * min(0, req) + temp
print(t)


import os
import sys

def log(*args, **kwargs):
	if os.environ.get('CODEFR'):
		print(*args, **kwargs)
n = int(input())
s = input()
minimum = 0
maximum = 0
value = 0
for i in s:
	if i == '-':
		value -= 1
	if i == '+':
		value += 1
	minimum = min(value, minimum)
print(value - minimum)


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


input()
cnt = 0
for i in input():
	if i == '+':
		cnt = cnt + 1
	elif cnt > 0:
		cnt = cnt - 1
print(cnt)


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


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


n = int(input())
s = input()
if s[0] == '-':
	c = 0
	for i in range(1, n):
		if s[i] == '-':
			c -= 1
			if c < 0:
				c = 0
		else:
			c += 1
	print(c)
else:
	c = 1
	for i in range(1, n):
		if s[i] == '-':
			c -= 1
			if c < 0:
				c = 0
		else:
			c += 1
	print(c)


n = int(input())
a = list(input())
k = 0
for i in a:
	if i == '+':
		k += 1
	elif k > 0:
		k -= 1
print(k)


n = int(input())
a = list(input())
mi = 0
last = 0
for i in a:
	if i == '-':
		last -= 1
		mi = min(mi, last)
	else:
		last += 1
print(abs(mi) + last)


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


n = int(input())
s = input()
res = 0
idx = 0
while idx < n:
	flag = 0
	while idx < n and s[idx] == '-' and (res > 0):
		res -= 1
		idx += 1
		flag = 1
	if idx < n and s[idx] == '+':
		while idx < n and s[idx] == '+':
			res += 1
			idx += 1
			flag = 1
	if idx < n and flag == 0:
		idx += 1
print(res)


n = int(input())
s = input()
mi = n
lol = 0
lo = 0
for i in s:
	if i == '-' and lol == 1 and (lo > 0):
		lo -= 1
	elif i == '+':
		lol = 1
		lo += 1
print(lo)


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


from sys import stdin
n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()
a = 0
for i in range(n):
	if s[i] == '-' and a == 0:
		a = 0
	elif s[i] == '-':
		a -= 1
	else:
		a += 1
print(a)


a = int(input())
x = input()
r = 0
for i in x:
	if r != 0 and i == '-':
		r -= 1
	elif i == '+':
		r += 1
print(r)


n = int(input())
a = list(input())
a.append('+')
w = 0
max1 = 0
c = 0
for i in range(n):
	if a[i] == '-':
		w -= 1
		c -= 1
	elif a[i] == '+':
		w += 1
		c += 1
	if w < 0:
		if max1 < -w:
			max1 = -w
print(max1 + c)


a = int(input())
s = input()
n = 0
for j in s:
	if j == '+':
		n += 1
	else:
		n -= 1
		if n == -1:
			n = 0
print(n)


n = int(input())
a = list(input())
f = 0
x = 0
for i in range(n):
	if a[i] == '-':
		x -= 1
		if f > x:
			f = x
	else:
		x += 1
print(x - f)


n = int(input())
actions = input().strip()
stone = 0
for action in actions:
	if action == '-':
		if stone > 0:
			stone -= 1
	else:
		stone += 1
print(stone)


n = int(input())
m = list(input())
a = 0
for i in m:
	if i == '+':
		a += 1
	elif i == '-' and a != 0:
		a -= 1
	elif i == '-' and a == 0:
		a = 0
print(a)


n = int(input())
s = input()
if s[0] == '+':
	kq = 0
else:
	kq = 1
for i in range(n):
	if s[i] == '-' and kq > 0:
		kq = kq - 1
	elif s[i] == '-' and kq == 0:
		kq = 0
	elif s[i] == '+':
		kq = kq + 1
print(kq)


def main():
	n = int(input())
	s = input()
	ans = 0
	for ch in s:
		if ch == '+':
			ans += 1
		elif ans > 0:
			ans -= 1
	print(ans)
main()


a = input
a()
k = a().lstrip('-')
c = 0
for i in k:
	if c > 0 and i == '-':
		c -= 1
	elif i == '+':
		c += 1
print(c)


n = int(input())
l = input()
c = 0
for i in l:
	if i == '+':
		c += 1
	elif c != 0:
		c -= 1
if c < 0:
	print(0)
else:
	print(c)


n = int(input())
s = input()
p = False
x = 0
for i in range(n):
	if not p and s[i] == '+':
		p = True
	if p:
		if s[i] == '+':
			x += 1
		elif x > 0:
			x -= 1
print(x)


num = int(input())
string = str(input())
total = 0
for (counter, item) in enumerate(string):
	if item == '-' and total == 0:
		continue
	elif item == '-' and total != 0:
		total = total - 1
	elif item == '+':
		total = total + 1
print(total)


n = int(input())
s = input()
ans = 0
minans = 0
maxans = 0
for i in range(len(s)):
	if s[i] == '+':
		ans += 1
	else:
		ans -= 1
		minans = min(ans, minans)
print(ans - minans)


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


input()
string = input()
cntr = 0
for i in string:
	if i == '-':
		cntr -= 1
	if cntr < 0:
		cntr = 0
	if i == '+':
		cntr += 1
print(cntr)


from itertools import accumulate
from sys import stdin

def main():
	N = int(input())
	S = input()
	x = [0]
	for s in S:
		if s == '-':
			x.append(-1)
		else:
			x.append(1)
	x = list(accumulate(x))
	if min(x) < 0:
		print(x[-1] - min(x))
	else:
		print(x[-1])
input = lambda : stdin.readline().rstrip()
main()


n = int(input())
array = list(input())
array = [1 if t == '+' else -1 for t in array]
array = [sum(array[:i]) for i in range(0, n + 1)]
array = [t + abs(min(array)) for t in array]
print(array[-1])


n = int(input())
str = input()
min = 0
for i in str:
	if i == '-':
		min -= 1
		if min < 0:
			min = 0
	else:
		min += 1
print(min)


from sys import *
from math import *
n = int(stdin.readline())
s = input()
f = 0
ans = 0
for i in range(n):
	if s[i] == '+':
		ans += 1
		f = 1
	if s[i] == '-':
		ans -= 1
		ans = max(ans, 0)
ans = max(0, ans)
print(ans)


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


n = int(input())
s = input()
k = minimo = menos = mais = 0
for i in range(n):
	if s[i] == '-':
		k -= 1
		menos += 1
		minimo = min(minimo, k)
	else:
		k += 1
		mais += 1
print(minimo * -1 - menos + mais)


while True:
	try:
		n = input()
		ops = input()
		sum = 0
		for i in ops:
			if i == '+':
				sum += 1
			elif i == '-' and sum == 0:
				pass
			elif i == '-' and sum != 0:
				sum -= 1
		if sum < 0:
			sum = 0
		print(sum)
	except EOFError:
		break


n = int(input())
s = input()
c = 0
d = 0
for _ in range(len(s)):
	if s[_] == '-':
		c -= 1
	else:
		c += 1
	d = min(d, c)
print(c - d)


n = int(input())
s = input()
(plus, minus) = (0, 0)
x = 0
for i in s:
	if i == '+':
		x += 1
	else:
		x -= 1
		if x < 0:
			x = 0
print(x)


input()
ops = input()
count = 0
for i in ops:
	if i == '+':
		count += 1
	elif count != 0:
		count -= 1
print(count)


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


import sys

def main():
	s = sys.stdin.read().strip().split()
	c = 0
	for i in s[1]:
		if i == '-':
			c = max(c - 1, 0)
		else:
			c += 1
	return c
print(main())


n = int(input())
s = tuple(input())
S = s[::-1]
count = 0
ubayimba = 0
if '-' in s:
	for i in range(n - S.index('-')):
		if s[i] == '+':
			count += 1
		elif s[i] == '-':
			if count == 0:
				ubayimba += 1
			else:
				count = count - 1
print(ubayimba + s.count('+') - s.count('-'))


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


n = int(input())
s = m = 0
for c in input():
	s += (1, -1)[c > '+']
	m = min(m, s)
print(s - m)


n = int(input())
s = input()
initial = 0
for a in range(len(s)):
	if s[a] == '+':
		initial = initial
		break
	else:
		initial += 1
for a in range(len(s)):
	if s[a] == '-':
		if initial - 1 < 0:
			initial = 0
		else:
			initial -= 1
	else:
		initial += 1
print(initial)


def go():
	n = int(input())
	a = [i for i in input()]
	x = 0
	for i in a:
		if i == '-':
			x = max(0, x - 1)
		else:
			x += 1
	return x
print(go())


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


n = int(input())
p = input()
t = 0
l = 0
for i in range(n):
	if p[i] == '+':
		t += 1
	elif t > 0:
		t -= 1
	else:
		l += 1
print(l + p.count('+') - p.count('-'))


n = int(input())
string = input()
lst = []
if string[0] == '+':
	lst.append(1)
else:
	lst.append(-1)
for i in range(1, n):
	if string[i] == '+' and string[i - 1] == '+':
		lst.append(lst[-1] + 1)
	elif string[i] == '+' and string[i - 1] == '-':
		lst.append(lst[-1] + 1)
	elif string[i] == '-' and string[i - 1] == '+':
		lst.append(lst[-1] - 1)
	else:
		lst.append(lst[-1] - 1)
z = abs(min(min(lst), 0))
for i in range(n):
	if string[i] == '+':
		z += 1
	else:
		z -= 1
print(z)


a = int(input())
b = str(input())
x = k = int(0)
while x < a:
	if b[x] == '+':
		k = k + 1
	elif k - 1 >= 0:
		k = k - 1
	x = x + 1
print(k)


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


num = int(input())
st = input()
i = 0
top = -1
lis = []
while i < len(st):
	if st[i] == '-':
		if top != -1:
			top = top - 1
	else:
		top = top + 1
	i = i + 1
if top <= -1:
	print(0)
else:
	print(top + 1)


n = int(input())
operations = input()
base = 0
state = 0
for operation in operations:
	if operation == '+':
		state += 1
	else:
		state -= 1
		if state < 0:
			base += 1
			state = 0
print(state)


n = int(input())
min = 0
pl = 0
nr = 0
ok = 0
s = [None] * n
s = input()
if s[0] == '-':
	nr = 1
for i in range(0, n):
	if s[i] == '-':
		nr = nr - 1
		min = min + 1
	else:
		nr = nr + 1
		pl = pl + 1
	if nr < 0:
		nr = nr + 1
		ok = 1
print(nr)


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


import sys
import collections
input = sys.stdin.readline

def printnl(val):
	sys.stdout.write(str(val) + '\n')
n = int(input())
s = list(input())[:n]
ans = 0
for i in range(n):
	if s[i] == '-':
		ans -= 1
		if ans < 0:
			ans = 0
	else:
		ans += 1
print(ans)


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


a = int(input())
b = input()
cnt = 0
for i in range(a):
	if b[i] == '+':
		cnt += 1
	elif b[i] == '-' and cnt > 0:
		cnt -= 1
	else:
		cnt = cnt
print(cnt)


Int = int(input())
String = input()
S = 0
for i in String:
	if i == '-':
		S = max(S - 1, 0)
	else:
		S += 1
print(S)


n = int(input())
s = input()
count = 0
izn = 0
for i in range(n):
	if s[i] == '+':
		count += 1
	else:
		count -= 1
		if count < 0:
			count += 1
print(count)


n = int(input())
s = input()
c = 0
flag = 0
for i in range(0, n):
	if s[i] == '-':
		if i == 0 or c == 0:
			c = 0
		elif flag == 1:
			c = c - 1
	elif s[i] == '+':
		flag = 1
		c = c + 1
if c >= 0:
	print(c)
else:
	print(0)


n = int(input())
s = input()
sumi = 0
l = [0]
for i in range(n):
	if s[i] == '+':
		sumi += 1
	else:
		sumi -= 1
	l.append(sumi)
z = min(l)
print(sumi - z)


n = input()
s = input()
answ = 0
bol = False
ind = 0
for i in s:
	if i == s[0] and i == '-':
		bol = True
		ind += 1
	elif bol and i != '-':
		s = s[ind:]
		break
	elif i == s[0] and i != '-':
		break
	else:
		ind += 1
for i in s:
	if i == '+':
		answ += 1
	else:
		answ -= 1
	if answ < 0:
		answ = 0
if answ < 0:
	answ = 0
print(answ)


n = int(input())
s = input()
cnt = 0
for i in s:
	if i == '-' and cnt > 0:
		cnt -= 1
	elif i == '+':
		cnt += 1
print(cnt)


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


x = int(input())
y = input()
for i in range(x + 1):
	worked = True
	count = i
	for j in range(len(y), 0, -1):
		if y[j - 1] == '-':
			count += 1
		elif y[j - 1] == '+':
			count -= 1
		if count < 0:
			worked = False
			break
	if worked == True:
		break
print(i)


n = int(input())
s = input()
minus = 0
plus = 0
preans = 0
for i in range(n):
	if s[i] == '-':
		minus += 1
	else:
		plus += 1
	if minus > plus and minus - plus > preans:
		preans = minus - plus
ans = preans - minus + plus
print(ans)


import sys
import math
import bisect

def main():
	A = [0]
	n = int(input())
	for c in input():
		if c == '-':
			A.append(A[-1] - 1)
		elif c == '+':
			A.append(A[-1] + 1)
	min_val = min(A)
	for i in range(len(A)):
		A[i] -= min_val
	print(A[-1])
main()


n = int(input())
s = list(input())[::-1]
r = 0
ml = 0
for i in range(0, len(s)):
	if s[i] == '-':
		r += 1
	else:
		r -= 1
	ml = min(ml, r)
print(-ml)


n = int(input())
t = input()
a = 0
for t1 in t:
	if t1 == '-':
		if t1 == '-' and a == 0:
			a = 0
		else:
			a = a - 1
	elif t1 == '+':
		a = a + 1
print(a)


input()
operations = [i for i in input()]
counter = 0
for i in operations:
	if i == '-' and counter > 0:
		counter -= 1
	elif i == '+':
		counter += 1
print(counter)


n = int(input())
s = input()
sm = 0
for i in s:
	if i == '+':
		sm += 1
	elif (i == '-') & (sm == 0):
		sm = sm
	else:
		sm -= 1
print(sm)


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


n = int(input())
s = input()
m = [0]
for i in range(n):
	if s[i] == '-':
		m.append(m[-1] - 1)
	else:
		m.append(m[-1] + 1)
ans = abs(min(m))
print(ans + m[-1])


n = int(input())
opr = input()
counter = 0
for i in opr:
	if i == '+':
		counter += 1
	elif counter > 0:
		counter -= 1
print(counter)


n = int(input())
s = input()
c = 0
for i in s:
	if c == 0 and i == '-':
		pass
	elif i == '+':
		c += 1
	else:
		c -= 1
print(c)


n = input()
s = input()
(tot, mini) = (0, 0)
for i in s:
	if i == '-':
		tot -= 1
	else:
		tot += 1
	mini = tot if tot < mini else mini
print(tot - mini)


n = int(input())
s = input()
i = 0
pile = 0
while i < n and s[i] == '-':
	i += 1
for j in range(i, n):
	if s[j] == '+':
		pile += 1
	else:
		pile = max(0, pile - 1)
print(pile)


i = int(input())
a = input().strip()
m = 0
for j in a:
	if m >= 0 and j == '+':
		m = m + 1
	if m > 0 and j == '-':
		m = m - 1
print(m)


n = int(input().strip())
string = input().strip()
ans = 0
for i in string:
	if i == '+':
		ans += 1
	if i == '-':
		ans -= 1
	if ans < 0:
		ans = 0
print(ans)


n = int(input())
s = input()
(cnt, min_cnt) = (0, 0)
for x in s:
	if x == '-':
		cnt -= 1
		min_cnt = min(min_cnt, cnt)
	else:
		cnt += 1
print(cnt - min_cnt)


n = int(input())
op = input()
(ar, c) = ([], 0)
for i in op:
	if i == '+':
		c += 1
		ar.append(c)
	else:
		c -= 1
		if c < 0:
			c = 0
		ar.append(c)
print(ar[-1])


a = int(input())
b = list(input())
k = l = j = 0
while 1:
	k = l
	j = 0
	for i in b:
		if i == '+':
			k += 1
		else:
			k -= 1
		if k < 0:
			j = 1
			l += 1
			break
	if j == 0:
		break
print(k)


n = int(input())
s = input()
negat = s.count('-')
posit = s.count('+')
begin = 0
c = 0
for i in s:
	if i == '-':
		if c - 1 < 0:
			begin += 1
		else:
			c -= 1
	elif i == '+':
		c += 1
print(begin + posit - negat)


n = int(input())
a = input()
mark = [_ for _ in range(101)]
for i in range(n):
	for j in range(101):
		if a[i] == '-':
			if mark[j] <= 0:
				mark[j] = 10000
			else:
				mark[j] -= 1
		else:
			mark[j] += 1
print(min(mark))


def read_nums():
	return [int(x) for x in input().split()]

def main():
	(n,) = read_nums()
	s = input()
	count = 0
	for ch in s:
		if ch == '+':
			count += 1
		else:
			count = max(count - 1, 0)
	print(count)
main()


n = int(input())
s = str(input())
n1 = 0
for i in range(n):
	if s[i] == '+':
		n1 = n1 + 1
	elif n1 >= 1:
		n1 = n1 - 1
print(n1)


num_ops = int(input())
ops = input()
stones = 0
for op in ops:
	if op == '+':
		stones += 1
	else:
		stones -= 1
	if stones < 0:
		stones = 0
print(stones)


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


a = int(input())
t = input()
p = 0
for j in t:
	if j == '+':
		p += 1
	elif p > 0:
		p -= 1
print(p)


n = int(input())
L = list(input())
br = 0
for i in L:
	if i == '-' and br != 0:
		br -= 1
	elif i == '+':
		br = br + 1
	else:
		br = 0
print(br)


n = int(input())
s = list(input())
c = 0
for i in s:
	if i == '+':
		c += 1
	elif c > 0:
		c -= 1
print(c)


n = int(input())
a = input()
x = 0
na = 0
for i in a:
	if i == '+':
		x += 1
	elif x == 0:
		na += 1
	else:
		x -= 1
for i in a:
	if i == '+':
		na += 1
	else:
		na -= 1
print(na)


n = input()
l = 0
h = 0
for x in input():
	if '-' == x:
		h -= 1
	else:
		h += 1
	l = min(l, h)
print(h - l)


n = int(input())
i = list(input())
pile = 0
for x in i:
	if x == '+':
		pile += 1
	elif pile > 0:
		pile -= 1
print(pile)


def pileStone(s):
	st = 0
	for i in s:
		if i == '+':
			st += 1
		else:
			st -= 1
			if st < 0:
				st = 0
	return st
n = int(input())
s = input()
print(pileStone(s))


input()
s = input()
counter = 0
for i in s:
	if i == '+':
		counter += 1
	elif counter > 0:
		counter -= 1
print(counter)


n = int(input())
s = input()
l = list(s)
count = 0
if '+' in l:
	i = 0
	while i < len(s):
		if s[i] == '-':
			count -= 1
			i += 1
		else:
			count += 1
			i += 1
		if count < 0:
			count = 0
	print(count)
else:
	print(count)


a = int(input())
operations = input()
min = int(0)
if a == len(operations):
	for x in range(0, a):
		if operations[x] == '+':
			min = min + 1
		elif operations[x] == '-':
			if min > 0:
				min = min - 1
print(min)


n = input()
s = input()
p = 0
m = 0
t = 0
for i in s:
	if i == '+':
		p += 1
		t += 1
	elif i == '-':
		m += 1
		if t == 0:
			t = 0
		else:
			t -= 1
print(t)


n = int(input())
inp = input()
minusCnt = 0
plusCnt = 0
qtd = 0
for s in inp:
	if s == '-':
		qtd = max(0, qtd - 1)
	else:
		qtd += 1
print(qtd)


n = int(input())
ops = input()
c = 0
for o in ops:
	if o == '-':
		c = c - 1 if c > 0 else 0
	else:
		c += 1
print(c)


gi = lambda : list(map(int, input().strip().split()))
(n,) = gi()
s = input()
ans = 0
for e in s:
	if e == '-':
		ans = max(ans - 1, 0)
	else:
		ans += 1
print(ans)


n = int(input())
res = 0
curr = 0
for c in input():
	if c == '-':
		curr -= 1
	else:
		curr += 1
	res = min(curr, res)
print(curr - res)


import copy
n = int(input(''))
t = input('')
i = 0
c = 0
while c == 0:
	found = 0
	r = copy.deepcopy(i)
	for j in range(len(t)):
		if t[j] == '+':
			r += 1
		else:
			r -= 1
			if r < 0:
				found = 1
				break
	if found == 1:
		i += 1
	else:
		break
print(r)


n = int(input())
a = list(input())
counter = 0
b = []
for item in a:
	if item == '-':
		counter -= 1
	else:
		counter += 1
	b.append(counter)
if min(b) <= 0:
	print(b[-1] + abs(min(b)))
else:
	print(b[-1])


n = int(input())
s = list(input())
count = 0
ans = 0
for i in range(len(s)):
	if s[i] == '+':
		count += 1
	elif count > 0:
		count -= 1
		continue
	else:
		ans += 1
for i in s:
	if i == '+':
		ans += 1
	else:
		ans -= 1
print(ans)


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


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


(i, r) = (input, 0)
i()
for x in i():
	r = max(0, r + [1, -1][x == '-'])
print(r)


n = int(input())
operations = input()
start = 0
for op in operations:
	if op == '+':
		start += 1
	else:
		start = max(0, start - 1)
print(start)


fast = lambda : stdin.readline().strip()
zzz = lambda : [int(i) for i in fast().split()]
(z, zz) = (input, lambda : list(map(int, z().split())))
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from re import *
from sys import *
from math import *
from heapq import *
from queue import *
from bisect import *
from string import *
from itertools import *
from collections import *
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from collections import Counter as cc
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def output(answer):
	stdout.write(str(answer))
num = int(z())
arr = fast()
lst = [0] * (num + 1)
for (i, j) in enumerate(arr):
	if j == '-':
		lst[i + 1] = -1 + lst[i]
	else:
		lst[i + 1] = 1 + lst[i]
t = min(lst)
ans = abs(t)
for i in arr:
	if i == '+':
		ans += 1
	else:
		ans -= 1
print(ans)


n = int(input())
op = list(input())
cont = 0
for o in op:
	if o == '+':
		cont += 1
	elif cont > 0:
		cont -= 1
print(cont)


n = int(input())
l = input()
s = 0
for c in l:
	if c == '+':
		s += 1
	else:
		s -= 1
		if s < 0:
			s = 0
print(s)


n = int(input())
a = list(input())
c = []
flag = 0
for i in range(101):
	k = i
	flag = 0
	for j in range(len(a)):
		if a[j] == '+':
			k += 1
		elif a[j] == '-' and k > 0:
			k -= 1
		else:
			flag = 1
			break
	if flag == 0:
		break
print(k)


n = int(input())
l = list(input())
a = 0
cur = 0
for i in range(n):
	if l[i] == '-':
		cur -= 1
		a = min(a, cur)
	else:
		cur += 1
print(cur - a)


import sys
import math
get_string = lambda : sys.stdin.readline().strip()
get_list = lambda : list(map(int, sys.stdin.readline().strip().split()))
get_intList_from_str = lambda : list(map(int, list(sys.stdin.readline().strip())))
get_strList_from_str = lambda : list(sys.stdin.readline().strip())
get_int = lambda : int(sys.stdin.readline().strip())
pt = lambda x: sys.stdout.write(str(x))
n = get_int()
lst = get_strList_from_str()
value = 0
for i in range(n):
	if lst[i] == '-':
		value = max(0, value - 1)
	else:
		value += 1
print(value)


no = input()
opeartions = input()
stack = list()
for opration in opeartions:
	if opration == '-' and len(stack) == 0:
		continue
	elif opration == '+':
		stack.append(1)
	else:
		stack.pop()
print(stack.__len__())


n = int(input())
x = input()
cur = 0
for c in x:
	if c == '-':
		while cur <= 0:
			cur += 1
		cur -= 1
	else:
		cur += 1
print(cur)


import sys
import math
import collections
from pprint import pprint as pp
mod = 1000000007

def vector(size, val=0):
	vec = [val for i in range(size)]
	return vec

def matrix(rowNum, colNum, val=0):
	mat = []
	for i in range(rowNum):
		collumn = [val for j in range(colNum)]
		mat.append(collumn)
	return mat
(n, s) = (int(input()), input())
ans = 0
for i in s:
	if i == '+':
		ans += 1
	else:
		ans = max(0, ans - 1)
print(ans)


n = int(input())
s = input()
ans = 0
for i in range(n):
	ans = max(ans, s[i:].count('+') - s[i:].count('-'))
print(ans)


from itertools import accumulate, chain
n = int(input())
op = input()
a = list(chain((0,), accumulate((1 if s == '+' else -1 for s in op))))
(m, _) = min(((v, i) for (i, v) in enumerate(a)))
print(a[-1] - m)


input()
s = 0
for op in input():
	if op == '+':
		s += 1
	elif s > 0:
		s -= 1
print(s)


from sys import stdin

def read_input():
	n = int(stdin.readline())
	moves = stdin.readline()
	return moves[:-1]
moves = read_input()
(cur_min, cur_sum) = (0, 0)
for move in moves:
	cur_sum += 1 if move == '+' else -1
	cur_min = min(cur_min, cur_sum)
print(cur_sum - cur_min)


a = int(input())
b = input()
sum = 0
for i in b:
	if i == '+':
		sum += 1
	elif sum > 0:
		sum -= 1
print(sum)


def main():
	n = int(input())
	s = input().rstrip()
	ans = 0
	for si in s:
		if si == '-':
			ans = max(ans - 1, 0)
		else:
			ans += 1
	print(ans)
main()


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
n = ii()
s = si()
mn = 100000
c = 0
j = 0
for i in range(101):
	c = i
	j = 0
	while j < n:
		if s[j] == '-':
			if c - 1 < 0:
				break
			else:
				c -= 1
		else:
			c += 1
		j += 1
	if j == n and c >= 0:
		mn = min(mn, c)
print(mn)


n = int(input())
string = str(input())
count = 0
for s in string:
	if s == '-':
		count -= 1
		count = max(count, 0)
	else:
		count += 1
print(count)


n = int(input())
s = input()
k = 0
ls = [k]
for i in range(n):
	if s[i] == '-':
		k -= 1
		ls.append(k)
	else:
		k += 1
		ls.append(k)
print(ls[-1] - min(ls))


n = int(input())
ol = list(input())
ol.reverse()
c = 0
pc = 0
for o in ol:
	if o == '+':
		if pc == 0:
			c += 1
		else:
			pc -= 1
	if o == '-':
		pc += 1
print(c)


n = int(input())
s = input()
c = 0
for j in range(len(s)):
	if s[j] == '-':
		if c > 0:
			c = c - 1
		else:
			c = 0
	else:
		c = c + 1
print(c)


T_ON = 0
DEBUG_ON = 0
MOD = 998244353

def solve():
	n = read_int()
	curr = 0
	MIN = float('inf')
	for c in input():
		if c == '+':
			curr += 1
		else:
			curr -= 1
		MIN = min(MIN, curr)
	if MIN < 0:
		curr += abs(MIN)
	print(curr)

def main():
	T = read_int() if T_ON else 1
	for i in range(T):
		solve()

def debug(*xargs):
	if DEBUG_ON:
		print(*xargs)
from collections import *
import math
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def read_int():
	return int(input())

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

def print_nums(nums):
	print(' '.join(map(str, nums)))

def YES():
	print('YES')

def Yes():
	print('Yes')

def NO():
	print('NO')

def No():
	print('No')

def First():
	print('First')

def Second():
	print('Second')

def fib(n):
	(a, b) = (0, 1)
	for _ in range(n):
		(a, b) = (b, a + b)
	return a

def fib_ns(n):
	assert n >= 1
	f = [0 for _ in range(n + 1)]
	f[0] = 0
	f[1] = 1
	for i in range(2, n + 1):
		f[i] = f[i - 1] + f[i - 2]
	return f

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def xgcd(a, b):
	(x0, x1, y0, y1) = (0, 1, 1, 0)
	while a != 0:
		((q, a), b) = (divmod(b, a), a)
		(y0, y1) = (y1, y0 - q * y1)
		(x0, x1) = (x1, x0 - q * x1)
	return (b, x0, y0)

def lcm(a, b):
	d = gcd(a, b)
	return a * b // d

def is_even(x):
	return x % 2 == 0

def is_odd(x):
	return x % 2 == 1

def modinv(a, m):
	(g, x, _) = xgcd(a, m)
	if g != 1:
		raise Exception('gcd(a, m) != 1')
	return x % m

def mod_add(x, y):
	x += y
	while x >= MOD:
		x -= MOD
	while x < 0:
		x += MOD
	return x

def mod_mul(x, y):
	return x * y % MOD

def mod_pow(x, y):
	if y == 0:
		return 1
	if y % 2:
		return mod_mul(x, mod_pow(x, y - 1))
	p = mod_pow(x, y // 2)
	return mod_mul(p, p)

def mod_inv(y):
	return mod_pow(y, MOD - 2)

def mod_div(x, y):
	return mod_mul(x, mod_inv(y))

def is_prime(n):
	if n == 1:
		return False
	for i in range(2, int(n ** 0.5) + 1):
		if n % i:
			return False
	return True

def gen_primes(n):
	P = [True for _ in range(n + 1)]
	P[0] = P[1] = False
	for i in range(int(n ** 0.5) + 1):
		if P[i]:
			for j in range(2 * i, n + 1, i):
				P[j] = False
	return P
main()


n = int(input())
d = input()
res_orig = 0
res_now = 0
for c in d:
	if res_now == 0 and c == '-':
		res_orig += 1
		continue
	if c == '+':
		res_now += 1
		continue
	else:
		res_now -= 1
print(res_now)


n = int(input())
s = input()[:n]
s = list(s)
f = 0
for i in range(len(s)):
	if s[i] == '-':
		if f == 0:
			f = 0
		else:
			f -= 1
	else:
		f += 1
print(f)


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


n = int(input())
s = input()
c = 0
for i in s:
	if i == '-' and (not c == 0):
		c -= 1
	elif i == '+':
		c += 1
print(c)


n = int(input())
l = list(input())
c = 0
for i in range(n):
	if c < 0:
		c += 1
	if l[i] == '+':
		c += 1
	else:
		c -= 1
print(max(0, c))


import math
import bisect
import heapq
from collections import defaultdict

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, x, y) = egcd(b % a, a)
		return (g, y - b // a * x, x)

def mulinv(b, n):
	(g, x, _) = egcd(b, n)
	if g == 1:
		return x % n

def isprime(n):
	for d in range(2, int(math.sqrt(n)) + 1):
		if n % d == 0:
			return False
	return True

def argsort(ls):
	return sorted(range(len(ls)), key=ls.__getitem__)

def f(p=0):
	if p == 1:
		return map(int, input().split())
	elif p == 2:
		return list(map(int, input().split()))
	elif p == 3:
		return list(input())
	else:
		return int(input())
n = f()
count = 0
s = input()
for i in range(n):
	if s[i] == '-':
		count -= 1
	else:
		count += 1
	if count < 0:
		count = 0
print(count)


from sys import stdin
sys_input = stdin.readline

def si():
	return sys_input().rstrip()

def ii():
	return int(si())

def sti():
	return si().split()

def iti():
	return map(int, sti())

def sli():
	return list(si())

def ili():
	return list(iti())

def main():
	stone_nums = [0] * (N + 1)
	for (i, s) in enumerate(S):
		if s == '-':
			stone_nums[i + 1] = stone_nums[i] - 1
		else:
			stone_nums[i + 1] = stone_nums[i] + 1
	min_stone = min(stone_nums)
	result = abs(min_stone) + stone_nums[-1]
	print(result)
	return
N = ii()
S = si()
main()


a = int(input())
b = list(input())
c = 0
for j in b:
	if j == '+':
		c += 1
	elif j == '-' and c > 0:
		c -= 1
print(c)


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


input()
s = m = 0
for c in input():
	s += (1, -1)[c > '+']
	m = min(m, s)
print(s - m)


input()
s = input()
net = 0
for c in s:
	if c == '+':
		net += 1
	elif net > 0:
		net -= 1
print(net)


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


n = int(input())
op = input()
flag = 0
stones = 0
for i in range(n):
	if op[i] == '-' and flag == 0:
		continue
	elif op[i] == '-' and flag:
		stones -= 1
	else:
		if not flag:
			flag = 1
		stones += 1
	if stones < 0:
		stones = 0
print(stones)


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


n = int(input())
s = str(input())
count = 0
for i in s:
	if i == '-':
		count = count - 1
	elif i == '+':
		count = count + 1
	if count < 0:
		count = 0
print(count)


N = int(input())
s = input()
ans = 0
for i in range(N):
	if s[i] == '-':
		ans -= 1
	else:
		ans += 1
	if ans < 0:
		ans = 0
print(ans)


n = int(input())
arr = input()
res = 0
for x in range(n):
	if arr[x] == '+':
		res = res + 1
	elif arr[x] == '-':
		if res != 0:
			res = res - 1
print(res)


input()
operations = [op for op in input()]
start_adding = False
count = 0
least = float('inf')
for op in operations:
	if count == 0 and op == '-':
		continue
	elif op == '-':
		count -= 1
	else:
		count += 1
	if least > count:
		least = count
print(count)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = 1
	rr = []
	for _ in range(t):
		n = I()
		s = S()
		r = 0
		for c in s:
			if c == '-':
				r -= 1
				if r < 0:
					r = 0
			else:
				r += 1
		rr.append(r)
	return JA(rr, '\n')
print(main())


input()
s = input()
stones = plus = 0
for c in s:
	if c == '-':
		stones = max(0, plus - 1)
		plus = max(0, plus - 1)
	else:
		stones += 1
		plus += 1
print(stones)


import sys
sys.stdin.readline().strip()
s = sys.stdin.readline().strip()
res = 0
for c in s:
	if c == '-':
		res = max(0, res - 1)
	else:
		res += 1
print(res)


def findMinInValue(arr):
	mxcnt = 0
	cnt = 0
	for i in arr:
		if i == '-':
			cnt += 1
		else:
			cnt -= 1
		if cnt > mxcnt:
			mxcnt = cnt
	val = mxcnt
	for i in arr:
		if i == '-':
			val -= 1
		else:
			val += 1
	return val
n = int(input())
arr = input()
print(findMinInValue(arr))


n = int(input())
ops = list(input())
ops.reverse()
current_total = 0
final = 0
for op in ops:
	if op == '-':
		current_total += 1
	else:
		current_total -= 1
		if current_total < 0:
			current_total += 1
			final += 1
print(final)


n = int(input())
stn = input()
s = t = 0
for c in stn:
	if c == '-':
		s -= 1
	else:
		s += 1
	if s < 0:
		s += 1
print(s)


n = int(input())
ops = input()
delta = 0
min_delta = 0
for op in ops:
	if op == '-':
		delta -= 1
	else:
		delta += 1
	min_delta = min(delta, min_delta)
print(-1 * min_delta + delta)


def solution(l1):
	i = 0
	ans = 0
	while i < len(l1):
		if l1[i] == '+':
			ans += 1
		if l1[i] == '-':
			ans = max(0, ans - 1)
		i += 1
	return ans

def answer():
	n = int(input())
	l1 = list(input())
	print(solution(l1))
answer()


n = int(input())
l = input()
count = 0
for i in range(n):
	if l[i] == '+':
		count += 1
	if count > 0 and l[i] == '-':
		count -= 1
print(count)


n = int(input())
B = {'+': 1, '-': -1}
A = [0] + [B[x] for x in input()]
C = [A[0]]
for i in range(1, len(A)):
	C += [C[-1] + A[i]]
print(sum(A) - min(C))


def run_commands(start, cmd):
	for c in cmd:
		if c == '-':
			start -= 1
		elif c == '+':
			start += 1
		if start < 0:
			return False
	return start
n = int(input())
cmd = list(input())
for start in range(0, 101):
	result = run_commands(start, cmd)
	if result is False:
		continue
	else:
		print(result)
		break


import itertools as it
input()
s = input()
deltas = list(map(lambda r: len(list(r[1])), it.groupby(s, lambda c: c)))
if s[0] == '-':
	deltas = deltas[1:]
res = 0
for (i, d) in enumerate(deltas):
	if i % 2 == 0:
		res += d
	else:
		res = max(0, res - d)
print(res)


T = int(input())
o = str(input())
n = 0
for i in range(T):
	if o[i] == '+':
		n += 1
	elif o[i] == '-' and n > 0:
		n -= 1
print(n)


n = int(input())
p = input()
val = 0

def pile(arg):
	coun = 0
	for it in p:
		if it == '+':
			arg += 1
		elif arg >= 1:
			arg -= 1
		else:
			coun = 1
			break
	if coun == 1:
		return 'a'
	else:
		return arg
while 6 == 6:
	jam = pile(val)
	if jam == 'a':
		val += 1
	else:
		print(jam)
		break


n = int(input())
pile = input()
pos = 0
neg = 0
initial = 0
total = 0
for p in pile:
	if p == '+':
		pos += 1
		total += 1
	else:
		neg += 1
		total -= 1
	if total < 0:
		initial = max(initial, abs(total))
print(initial + pos - neg)


n = int(input())
o = input()
l = list(o)
ans = 0
cnt = 0
for i in range(n - 1, -1, -1):
	if l[i] == '+':
		cnt += 1
	else:
		cnt -= 1
	ans = max(cnt, ans)
print(ans)


def main():
	input()
	actions = input()
	min_stones = 0
	final_stones = 0
	for action in actions:
		if action == '-':
			final_stones -= 1
			min_stones = min(min_stones, final_stones)
		else:
			final_stones += 1
	min_stones = min(min_stones, 0)
	final_stones -= min_stones
	print(final_stones)
main()


t = int(input())
s = input()
cnt = 0
for i in s:
	if i == '+':
		cnt += 1
	else:
		cnt -= 1
		if cnt <= 0:
			cnt = 0
print(cnt)


import os
import sys
from io import BytesIO, IOBase
import math
from decimal import Decimal
from decimal import *
from collections import defaultdict, deque
import heapq
from decimal import Decimal
getcontext().prec = 25
abcd = 'abcdefghijklmnopqrstuvwxyz'
ABCD = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
MOD = 1000000007
BUFSIZE = 8192
from bisect import bisect_left, bisect_right

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
n = int(input())
l = input()
v = 0
t = 0
for i in l:
	if i == '-':
		if t == 0:
			v += 1
		else:
			t -= 1
	else:
		t += 1
print(t)


n = int(input())
ops = input()
curr = 0
ans = 0
for op in ops:
	curr += -1 if op == '-' else 1
	ans = max(ans, -curr)
for op in ops:
	ans += -1 if op == '-' else 1
print(ans)


(n, s, m, a) = (int(input()), input(), 0, 0)
i = n - 1
while i >= 0:
	if s[i] == '+':
		m += 1
	else:
		m -= 1
	a = max(a, m)
	i -= 1
print(a)


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


def mp():
	return map(int, input().split())
n = int(input())
s = input()
p = s.count('+')
m = n - p
c = 0
for i in s:
	if i == '-':
		c = max(0, c - 1)
	else:
		c += 1
print(c)


import sys
from collections import *
from math import *
import re

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

def inp():
	return map(int, input().split())

def lcm(a, b):
	return a * b / gcd(a, b)

def iseven(n):
	return [False, True][0 if n % 2 else 1]
max_int = sys.maxsize
mod = 10 ** 9 + 7
n = int(input())
s = input()
piles = 0
for i in s:
	if piles == 0 and i == '-':
		continue
	elif i == '+':
		piles += 1
	else:
		piles -= 1
print(piles)


n = int(input())
symbols = input()
totals = 0
for character in symbols:
	if character == '-':
		totals = max(0, totals - 1)
	if character == '+':
		totals += 1
print(totals)


n = int(input())
s = input()
count = 0
for symbols in s:
	if count == 0:
		if symbols == '-':
			pass
		elif symbols == '+':
			count += 1
	elif symbols == '-':
		count -= 1
	elif symbols == '+':
		count += 1
print(count)


n = int(input())
b = []
c = 0
a = list(input())
for i in range(n):
	if a[i] == '+':
		c += 1
	else:
		c -= 1
	b.append(c)
print(b[len(b) - 1] if min(b) >= 0 else -min(b) + b[len(b) - 1])


n = int(input())
sk = list(input())
ats = 0
curr = 0
for c in sk:
	if c == '+':
		curr += 1
	else:
		curr -= 1
	ats = min(ats, curr)
print(-ats + curr)


n = int(input())
s = str(input())
x = 0
if n == len(s):
	for i in range(len(s)):
		if s[i] == '-':
			x = x - 1
			if x < 0:
				x = 0
		elif s[i] == '+':
			x = x + 1
print(x)


n = int(input())
s = str(input())
cnt = 0
cnt_after_min = 0
min_so_far = 0
for (i, c) in enumerate(s):
	if c == '-':
		cnt -= 1
		cnt_after_min -= 1
		if cnt <= min_so_far:
			min_so_far = cnt
			cnt_after_min = 0
	else:
		cnt += 1
		cnt_after_min += 1
print(cnt_after_min)


n = int(input())
s = input()
tot = 0
for item in s:
	if item == '+':
		tot = tot + 1
	elif tot > 0:
		tot = tot - 1
print(tot)


n = int(input())
seq = input()
pilha2 = 0
for i in range(0, len(seq)):
	if seq[i] == '-':
		pilha2 += 1
	if seq[i] == '+':
		break
for j in range(0, len(seq)):
	if seq[j] == '+':
		pilha2 += 1
	if seq[j] == '-':
		if pilha2 == 0:
			pilha2 += 1
		pilha2 -= 1
print(pilha2)


n = input()
s = input()
for a in range(101):
	b = a
	for c in s:
		b = b + 1 if c == '+' else b - 1
		if b < 0:
			break
	if b >= 0:
		print(b)
		break


n = input()
l = input()
k = len(l)
cnt = 0
for i in range(k):
	if l[i] == '-' and cnt <= 0:
		cnt = 0
	elif l[i] == '-' and cnt > 0:
		cnt = cnt - 1
	else:
		cnt += 1
if cnt >= 0:
	print(cnt)
else:
	print('0')


n = input()
n = int(n)
s = input()
k = 0
mini = 0
for i in range(n):
	if s[i] == '+':
		k += 1
	else:
		k -= 1
	if k < mini:
		mini = k
k = abs(mini)
for i in range(n):
	if s[i] == '+':
		k += 1
	else:
		k -= 1
print(k)


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


n = int(input())
s = input()
bal = 0
min_bal = 0
for i in range(n):
	if s[i] == '-':
		bal -= 1
	else:
		bal += 1
	min_bal = min(min_bal, bal)
print(bal - min_bal)


n = int(input())
a = list(input())
k = 0
start = 0
minus = 0
plus = 0
for i in range(n):
	if a[i] == '-':
		if k == 0:
			start += 1
		else:
			k -= 1
	else:
		k += 1
	if a[i] == '-':
		minus += 1
	else:
		plus += 1
print(start + plus - minus)


a = int(input())
w = input()
b = list(w)
r = 0
if b[0] == '+':
	i = 0
elif b[0] == '-':
	for k in b:
		if k == '-':
			r = r + 1
		elif k == '+':
			break
	i = r
for j in b:
	if j == '+':
		i = i + 1
	elif j == '-' and i >= 0:
		i = i - 1
		if i >= 0:
			i = i
		else:
			i = i + 1
print(i)


n = input()
s = input()
l = list(s)
count = 0
for i in s:
	if i == '+':
		count += 1
	elif i == '-' and count > 0:
		count -= 1
print(count)


n = int(input())
seq = input()
res = 0
for i in range(n):
	if seq[i] == '+':
		res += 1
	elif seq[i] == '-':
		if res > 0:
			res -= 1
print(res)


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


n = int(input())
stone = input()
count_add = 0
for i in stone:
	if i == '+':
		count_add += 1
	elif i == '-':
		if count_add > 0:
			count_add -= 1
print(count_add)


n = int(input())
c = 0
for x in list(input()):
	if x == '+':
		c += 1
	elif c > 0:
		c -= 1
	else:
		c = 0
print(c)


n = int(input())
moves = input()
plusCount = 0
minusCount = 0
maxMinus = 0
for i in moves:
	if i == '+':
		plusCount += 1
	else:
		minusCount += 1
		maxMinus = max(maxMinus, minusCount - plusCount)
print(maxMinus + plusCount - minusCount)


def main():
	n = int(input())
	s = input()
	for i in range(n + 1):
		flag = True
		stones = i
		for j in s:
			if j == '-':
				if stones > 0:
					stones -= 1
				else:
					flag = False
					break
			else:
				stones += 1
		if flag:
			n = i
			break
	stones = n
	for i in s:
		if i == '-':
			stones -= 1
		else:
			stones += 1
	print(stones)
main()


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


n = int(input())
stri = input()
summ = 0
for i in stri:
	if i == '-' and summ > 0:
		summ -= 1
	if i == '+':
		summ += 1
print(summ)


n = int(input())
A = input()
A = list(A)
i = 0
while i < n:
	if A[i] == '+':
		A[i] = 1
	else:
		A[i] = -1
	i = i + 1
s = sum(A)
i = 0
max = 0
while i < n:
	if s > max:
		max = s
	s = s - A[i]
	i = i + 1
print(max)


(n, m, c) = (int(input()), 0, 0)
for ch in input():
	if ch == '+':
		c += 1
	else:
		c -= 1
		m = min(m, c)
print(c - m)


a = int(input())
b = list(input())
count = 0
for x in range(a):
	if b[x] == '+':
		count += 1
	elif count > 0:
		count -= 1
print(count)


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


n = int(input())
operations = input()
stones = 0
for operation in operations:
	if operation == '-':
		if stones > 0:
			stones -= 1
	elif operation == '+':
		stones += 1
print(stones)


import sys
from collections import defaultdict as dc
from collections import Counter
from bisect import bisect_right, bisect_left
import math
from operator import itemgetter
from heapq import heapify, heappop, heappush
n = int(input())
s = input()
p = 0
for i in s:
	if i == '+':
		p += 1
	elif p > 0:
		p -= 1
print(p)


n = int(input())
s = input()
flag = 0
index = 0
for i in range(n):
	if s[i] == '-':
		continue
	else:
		index = i
		flag = 1
		break
if flag == 0:
	print(0)
else:
	count = 0
	for j in range(index, n):
		if s[j] == '-' and count > 0:
			count -= 1
		elif s[j] == '+':
			count += 1
	if count < 0:
		print(0)
	else:
		print(count)


def check(x, s):
	for i in s:
		if i == '-':
			x -= 1
		else:
			x += 1
		if x < 0:
			return -1
	return x
n = int(input())
s = input()
ans = 2 * n
for i in range(2 * n):
	x = check(i, s)
	if x == -1:
		continue
	else:
		ans = min(ans, x)
print(ans)


n = int(input())
s = str(input())
e = 0
f = 0
for i in range(0, len(s)):
	if s[i] == '+':
		f = f + 1
		pass
	elif f > 0:
		f = f - 1
	else:
		e = e + 1
for i in range(0, len(s)):
	if s[i] == '+':
		e = e + 1
	else:
		e = e - 1
print(e)


input()
s = input()
k = 0
r = 0
for i in s:
	if i == '+':
		r += 1
	else:
		r -= 1
	k = min(r, k)
print(-1 * k + r)


input()
s = input()
res = 0
for i in s:
	res += 1 if i == '+' else -(res != 0)
print(res)


p = int(input())
k = [str(x) for x in input()]
y = 0
for i in range(len(k)):
	if k[i] == '-':
		y -= 1
	elif k[i] == '+':
		y += 1
	if y < 0:
		y = 0
print(y)


n = input()
st = input()
cnt = 0
for s in st:
	if s == '+':
		cnt += 1
	else:
		cnt -= 1
		if cnt < 0:
			cnt = 0
if cnt < 0:
	print('0')
else:
	print(cnt)


n = int(input())
op = list(input())
flag = 0
sum = 0
for i in op:
	if i == '-':
		sum += -1
		if sum < 0:
			sum = 0
	if i == '+':
		sum += 1
print(sum)


n = int(input())
st = input()
arr = [c for c in st]
a = 0
m = 0
for i in range(n - 1, -1, -1):
	if arr[i] == '+':
		m += 1
	else:
		m -= 1
	a = max(a, m)
print(a)


n = 0
c = 0
num = 0
list = []
n = input()
list = input()
for i in range(len(list)):
	if num > 0 and list[i] == '-':
		num -= 1
	elif list[i] == '+':
		num += 1
print(num)


n = int(input())
s = input().strip()
ret = 1 << 30
for start in range(n + 1):
	have = start
	for op in s:
		if op == '-' and have == 0:
			break
		have += -1 if op == '-' else 1
	else:
		ret = min(ret, have)
print(ret)


n = int(input())
s = input()
t = 0
mt = 0
a = 0
for i in range(n):
	if s[i] == '+':
		t += 1
		mt = min(mt, t)
	else:
		t -= 1
		mt = min(mt, t)
a = -mt
for i in range(n):
	if s[i] == '+':
		a += 1
	else:
		a -= 1
print(a)


operation = int(input())
str = input()
cnt = 0
for (index, ch) in enumerate(str):
	if ch == '-':
		if index is 0:
			continue
		cnt -= 1
	elif ch == '+':
		cnt += 1
	if cnt < 0:
		cnt = 0
print(cnt)


x = int(input())
a = input()
t = 0
if a[0] == '+':
	t = 1
else:
	t = 0
for i in range(1, x):
	if a[i] == '+':
		t = t + 1
	elif t > 0:
		t = t - 1
print(t)


n = int(input())
ops = input()
resp = 0
for op in ops:
	if op == '-':
		resp = max(0, resp - 1)
	else:
		resp += 1
print(resp)


n = int(input())
s = input()
ind = 0
for i in range(n):
	if s[i] == '+':
		ind = i
		break
ans = 0
for i in range(ind, n):
	if s[i] == '+':
		ans += 1
	elif s[i] == '-' and ans > 0:
		ans -= 1
print(ans)


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


n = int(input())
entrada = []
entrada = input()
mais = 0
for i in entrada:
	if i == '-':
		if mais > 0:
			mais = mais - 1
	elif i == '+':
		mais = mais + 1
print(mais)


n = int(input())
cur = [0]
count = 0
for el in input():
	if el == '-':
		count += 1
		cur.append(cur[-1] - 1)
	else:
		cur.append(cur[-1] + 1)
print(-min(cur) + n - 2 * count)


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


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


nOperacoes = int(input())
operacoes = input()
start = False
contador = 0
for i in range(len(operacoes)):
	if operacoes[i] == '+':
		start = True
	if start == True:
		if operacoes[i] == '-':
			if contador != 0:
				contador -= 1
		else:
			contador += 1
print(contador)


n = int(input())
s = input()
c = 0
ans = 0
for i in s:
	if i == '-':
		c -= 1
	else:
		c += 1
	ans = min(ans, c)
st = abs(ans)
for i in s:
	if i == '-':
		st -= 1
	else:
		st += 1
print(st)


n = int(input())
start = 0
step = 0
line = list(input())
for i in line:
	if i == '+':
		step += 1
	elif step == 0:
		pass
	else:
		step -= 1
print(step)


n = int(input())
ops = input()
bal = 0
min_bal = 0
for op in ops:
	if op == '-':
		bal -= 1
	else:
		bal += 1
	min_bal = min(min_bal, bal)
print('{}'.format(min_bal * -1 + bal))


import math
n = int(input())
s = list(input())
lvl = 0
mlvl = 0
for i in range(n):
	if s[i] == '-':
		lvl -= 1
	else:
		lvl += 1
	mlvl = min(lvl, mlvl)
mlvl = abs(mlvl)
start = mlvl
for i in range(n):
	if s[i] == '-':
		start -= 1
	else:
		start += 1
print(start)


k = input()
s = input().strip()
count = 0
for x in s:
	if count and x == '-':
		count -= 1
	elif x == '+':
		count += 1
	else:
		pass
print(count)


n = int(input())
s = input()
n = len(s)
ch = 0
maxi = 0
for i in range(n - 1, -1, -1):
	if s[i] == '+':
		ch += 1
	elif s[i] == '-':
		ch -= 1
	maxi = max(maxi, ch)
print(maxi)


n = int(input())
k = input()
counter1 = 0
counter2 = 0
for i in range(len(k)):
	if k[i] == '-':
		counter1 -= 1
	else:
		counter1 += 1
	if counter2 > counter1:
		counter1 = counter2
print(counter1)


i = int(input())
j = str(input())
total = 0
test = []
for i in j:
	if i == '+':
		total = total + 1
		test.append(total)
	else:
		total = total - 1
		test.append(total)
number_of_stones = min(test)
number_of_stones = abs(min(number_of_stones, 0))
minus = j.count('-')
plus = j.count('+')
total = number_of_stones + plus * 1 - minus * 1
print(total)


n = int(input())
b = input()
pile = 0
for i in range(n):
	if b[i] == '+':
		pile += 1
	elif b[i] == '-' and pile == 0:
		continue
	else:
		pile -= 1
print(pile)


N = int(input())
S = input()
n = 0
for s in S:
	if s == '-':
		if n > 0:
			n -= 1
	elif s == '+':
		n += 1
print(n)


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


n = int(input())
s = input()
ss = []
ans = 0
cur = 0
for i in range(n):
	if s[i] == '-':
		if cur == 0:
			ans += 1
		else:
			cur -= 1
	else:
		cur += 1
print(ans - s.count('-') + s.count('+'))


import sys

def count_stones(n, s):
	current = 0
	max_negative_current = 0
	for i in range(n):
		if s[i] == '-':
			current -= 1
		else:
			current += 1
		max_negative_current = min(max_negative_current, current)
	return -max_negative_current + current
n = int(input())
s = input()
print(count_stones(n, s))


n = int(input())
s = input()
ind = 0
if s[0] == '-':
	for i in range(n):
		if s[i] == '-':
			continue
		else:
			break
	ind = i
	if ind == n - 1 and s[ind] == '-':
		print(0)
	else:
		c = 0
		for i in range(ind, n):
			if s[i] == '+':
				c += 1
			else:
				c -= 1
			if c < 0:
				c = 0
		print(c)
else:
	c = 0
	for i in range(n):
		if s[i] == '+':
			c += 1
		else:
			c -= 1
		if c < 0:
			c = 0
	print(c)


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


num = eval(input())
cz = input()
ans = 0
for c in cz:
	if c == '-':
		if ans != 0:
			ans -= 1
		else:
			ans = 0
	else:
		ans += 1
print(ans)


import math
n = int(input())
s = input()
ans = 0
for i in range(0, len(s)):
	if s[i] == '-' and ans > 0:
		ans = ans - 1
	elif s[i] == '+':
		ans = ans + 1
	else:
		continue
print(ans)


n = input()
n = int(n)
s = input()
pos = 0
neg = 0
ans = 0
for i in range(n):
	if s[i] == '-':
		ans = ans - 1
		if ans < 0:
			ans = ans + 1
	elif s[i] == '+':
		ans = ans + 1
		if ans < 0:
			ans = ans + 1
print(ans)


input()
s = input()
while '+-' in s:
	s = s.replace('+-', '')
print(max(s.count('+') - s.count('-'), len(s) - len(s.rstrip('+'))))


n = int(input())
m = input()
l = []
c = 0
for i in range(0, n):
	if m[i] == '+':
		c += 1
	elif c > 0:
		c -= 1
print(c)


ops_count = int(input())
ops = input()
x = 0
for i in range(ops_count):
	x = max(0, x + (-1 if ops[i] == '-' else 1))
print(x)


def getn():
	return int(input())

def getns():
	return [int(x) for x in input().split()]
n = getn()
s = input()
ans = 0
m = 0
for c in s:
	if c == '-':
		ans -= 1
	else:
		ans += 1
	m = min(m, ans)
print(ans - m)


n = int(input())
l = list(input())
(count, z) = (0, True)
i = 0
for i in range(len(l)):
	if l[i] == '-':
		count -= 1
		if count < 0:
			count = 0
	else:
		count += 1
print(count)


def main():
	n = int(input())
	s = input()
	ret = 0
	for c in s:
		if c == '-':
			ret = max(0, ret - 1)
		else:
			ret += 1
	print(ret)
main()


n = int(input())
s = input()
ans = 0
for si in s:
	if si == '-':
		if ans > 0:
			ans -= 1
	else:
		ans += 1
print(ans)


n = int(input())
s = input()
l = []
val = 0
l.append(0)
for i in range(0, n):
	if s[i] == '-':
		val = val - 1
		l.append(val)
	else:
		val = val + 1
		l.append(val)
mn = min(l)
val = -mn
for i in range(0, n):
	if s[i] == '-':
		val = val - 1
	else:
		val = val + 1
print(val)


IL = lambda : list(map(int, input().split()))
n = input()
S = input()
ans = 0
for s in S:
	if s == '+':
		ans += 1
	elif ans:
		ans -= 1
print(ans)


input()
r = 0
for c in input():
	r = max(0, r + (c < '-') * 2 - 1)
print(r)


n = int(input())
s = input()
mx = 0
real = 0
for i in range(n):
	if s[i] == '-':
		real -= 1
		if real < 0:
			mx += 1
			real = 0
	else:
		real += 1
print(real)


num = int(input())
(mi, ma, p) = (0, 0, 0)
s = input()
for f in list(s):
	if f == '+':
		p += 1
	else:
		p -= 1
		if p < mi:
			mi = p
print(p - mi)


n = int(input())
s = input()
nr = 0
for c in s:
	if c == '+':
		nr += 1
	elif nr != 0:
		nr -= 1
print(nr)


n = int(input())
s = str(input())
p = 0
for ch in s:
	if ch == '-':
		if p > 0:
			p -= 1
		else:
			continue
	else:
		p += 1
print(p)


(n, cnt) = (int(input()), 0)
list = [0]
s = input()
for ch in s:
	if ch == '-':
		cnt -= 1
		if cnt < 0:
			list.append(abs(cnt))
	else:
		cnt += 1
k = max(list)
for ch in s:
	if ch == '-':
		k -= 1
	else:
		k += 1
print(k)


x = int(input())
s = input()
sum = 0
tmp = ''
for char in s:
	if char == '+':
		sum = sum + 1
	elif char == '-':
		sum = sum - 1
	if sum < 0:
		sum = 0
print(sum)


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


def main():
	n = int(input())
	s = input()
	mi = 0
	c = 0
	for i in s:
		if i == '+':
			c += 1
		else:
			c -= 1
		mi = min(mi, c)
	print(c - mi)
	return 0
main()


import sys
input = sys.stdin.readline

def main():
	n = int(input())
	s = input().strip()
	initalVal = 0
	r = 0
	for i in range(n):
		if s[i] == '+':
			r += 1
		elif r == 0:
			initalVal += 1
		else:
			r -= 1
	print(r)
main()


n = int(input())
s = input()
ans = 10000
for i in range(0, 105):
	f = True
	x = i
	for c in s:
		if c == '-':
			x -= 1
		else:
			x += 1
		if x < 0:
			f = False
	if f:
		ans = min(ans, x)
print(ans)


n = int(input())
op = input()
rocks = 0
for c in op:
	if c == '+':
		rocks += 1
	elif rocks == 0:
		continue
	else:
		rocks -= 1
print(rocks)


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


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


a = int(input())
b = input()
c = 0
for x in b:
	if x == '-' and c != 0:
		a += 1
		c -= 1
	elif x == '+' and a > 0:
		a -= 1
		c += 1
print(c)


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


import sys

def main():
	pass

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def lts(l):
	s = ''.join(map(str, l))
	return s

def stl(s):
	l = list(s)
	return l

def sq(a, target, arr=[]):
	s = sum(arr)
	if s == target:
		return arr
	if s >= target:
		return
	for i in range(len(a)):
		n = a[i]
		remaining = a[i + 1:]
		ans = sq(remaining, target, arr + [n])
		if ans:
			return ans

def SieveOfEratosthenes(n):
	cnt = 0
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			cnt += 1
	return cnt

def nCr(n, r):
	f = math.factorial
	return f(n) // f(r) // f(n - r)
mod = int(1000000000.0) + 7

def ssinp():
	return sys.stdin.readline().strip()

def iinp():
	return int(input())

def nninp():
	return map(int, sys.stdin.readline().strip().split())

def llinp():
	return list(map(int, sys.stdin.readline().strip().split()))

def p(xyz):
	print(xyz)

def p2(a, b):
	print(a, b)
import math
n = iinp()
s = ssinp()
sum = ans = 0
for c in s:
	if c == '+':
		sum += 1
	else:
		sum -= 1
	ans = min(ans, sum)
p(sum - ans)


n = int(input())
s = input()
mi = 0
for i in s:
	if i == '-' and mi == 0:
		mi += 0
	elif i == '-' and mi > 0:
		mi -= 1
	else:
		mi += 1
print(mi)


n = int(input())
s = input()
m = n
x = n
for i in range(n):
	if s[i] == '-':
		x -= 1
	else:
		x += 1
	if x < m:
		m = x
y = x
x = n
st = n - m
d = abs(x - st)
if st >= x:
	print(y + d)
else:
	print(y - d)


n = int(input())
s = input()
pile = 0
minp = 0
now = 0
for i in range(0, n):
	pile = pile - (s[i] == '-') + (s[i] == '+')
	now = now - (s[i] == '-') + (s[i] == '+')
	if pile < minp:
		minp = pile
		now = 0
print(now)


input()
s = input()
m = 0
n = 0
plus = 0
minus = 0
for c in s:
	if c == '+':
		n += 1
		plus += 1
	else:
		n -= 1
		minus += 1
		m = min(m, n)
print(-m + plus - minus)


n = int(input())
s = list(input())
f = 0
for i in s:
	if i == '+':
		f += 1
	elif i == '-' and f != 0:
		f -= 1
print(f)


n = int(input())
st = input()
kol = 0
for i in range(n):
	if st[i] == '-':
		if kol != 0:
			kol -= 1
	else:
		kol += 1
print(kol)


n = int(input())
s = input()
ini = 0
sta = 0
for i in range(n):
	if s[i] == '-':
		if sta == 0:
			ini += 1
		else:
			sta -= 1
	if s[i] == '+':
		sta += 1
print(sta)


n = int(input())
string = input()
ns = 0
for i in range(n):
	if string[i] == '-':
		if ns > 0:
			ns -= 1
		else:
			ns = 0
	else:
		ns += 1
print(ns)


i = int(input())
ar = input()
res = 0
if i > 0:
	for i in range(0, i):
		if res == 0 and ar[i] != '-' or ar[i] == '+':
			res = res + 1
		elif res != 0 and ar[i] == '-':
			res = res - 1
print(max(res, 0))


n = int(input())
s = input()
count = 0
for each in s:
	if each == '+':
		count = count + 1
	elif count > 0:
		count = count - 1
print(count)


a = int(input())
op = list(input())
store = True
ans = 0
test = 0
while store:
	ans = test
	for i in range(a):
		if op[i] == '+':
			ans += 1
		else:
			ans -= 1
		if ans < 0:
			break
	if ans >= 0:
		store = False
	test += 1
print(ans)


n = int(input())
lis = list(input())
ans = 0
for i in lis:
	if i == '-':
		if ans != 0:
			ans -= 1
	else:
		ans += 1
print(ans)


def main():
	x = int(input())
	i = 0
	mas = []
	ch = 0
	nums = input()
	while i < x:
		s = nums[i]
		mas.append(s)
		i += 1
	for i in range(0, len(mas)):
		if mas[i] == '-' and i != 0:
			ch -= 1
		if mas[i] == '+':
			ch += 1
		if ch < 0:
			ch = 0
	print(ch)
main()


from math import *
from cmath import *
from itertools import *
from decimal import *
from fractions import *
from sys import *
for _ in range(1):
	n = int(input())
	s = input()
	ans = 0
	for x in s:
		if ans > 0 and x == '-':
			ans -= 1
		elif x == '+':
			ans += 1
	print(ans)


n = int(input())
a = input()
res = 0
for i in range(n):
	if a[i] == '-':
		res -= 1
	elif a[i] == '+':
		if res < 0:
			res = 1
		else:
			res += 1
if res < 0:
	res = 0
print(res)


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


import sys, os
f = lambda : list(map(int, input().split()))
if 'local' in os.environ:
	sys.stdin = open('./input.txt', 'r')

def solve():
	n = f()[0]
	s = input()
	ans = 0
	for i in s:
		if i == '-':
			ans = max(0, ans - 1)
		if i == '+':
			ans = ans + 1
	print(ans)
solve()


def P1323A():
	t = int(input())
	l = []
	for i in range(t):
		n = int(input())
		a = input().split()
		a = [int(j) for j in a]
		if len(a) == 1 and a[0] % 2 != 0:
			l.append('-1')
			continue
		for k in range(2):
			if a[k] % 2 == 0:
				l.append(1)
				l.append(k + 1)
				break
			elif k > 0:
				l.append('2')
				l.append('1 2')
				break
	for i in l:
		print(i)

def P1159A():
	n = int(input())
	s = input()
	t = 0
	for i in s:
		if i == '-' and t == 0:
			continue
		if i == '-':
			t -= 1
		if i == '+':
			t += 1
	print(t)
P1159A()


num = int(input())
pm = input()
min_ = 0
hg = 0
for i in range(num):
	if pm[i] == '+':
		hg += 1
	else:
		hg -= 1
	if hg < min_:
		min_ = hg
print(hg - min_)


from sys import stdin, stdout
import cProfile, math
from collections import Counter, defaultdict, deque
from bisect import bisect_left, bisect, bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
import operator as op
from functools import reduce
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)
fac_warmup = False
printHeap = str()
memory_constrained = False
P = 10 ** 9 + 7
import sys

class merge_find:

	def __init__(self, n):
		self.parent = list(range(n))
		self.size = [1] * n
		self.num_sets = n
		self.lista = [[_] for _ in range(n)]

	def find(self, a):
		to_update = []
		while a != self.parent[a]:
			to_update.append(a)
			a = self.parent[a]
		for b in to_update:
			self.parent[b] = a
		return self.parent[a]

	def merge(self, a, b):
		a = self.find(a)
		b = self.find(b)
		if a == b:
			return
		if self.size[a] < self.size[b]:
			(a, b) = (b, a)
		self.num_sets -= 1
		self.parent[b] = a
		self.size[a] += self.size[b]
		self.lista[a] += self.lista[b]

	def set_size(self, a):
		return self.size[self.find(a)]

	def __len__(self):
		return self.num_sets

def display(string_to_print):
	stdout.write(str(string_to_print) + '\n')

def primeFactors(n):
	factors = dict()
	for i in range(2, math.ceil(math.sqrt(n)) + 1):
		while n % i == 0:
			if i in factors:
				factors[i] += 1
			else:
				factors[i] = 1
			n = n // i
	if n > 2:
		factors[n] = 1
	return factors

def all_factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def fibonacci_modP(n, MOD):
	if n < 2:
		return 1
	return (cached_fn(fibonacci_modP, (n + 1) // 2, MOD) * cached_fn(fibonacci_modP, n // 2, MOD) + cached_fn(fibonacci_modP, (n - 1) // 2, MOD) * cached_fn(fibonacci_modP, (n - 2) // 2, MOD)) % MOD

def factorial_modP_Wilson(n, p):
	if p <= n:
		return 0
	res = p - 1
	for i in range(n + 1, p):
		res = res * cached_fn(InverseEuler, i, p) % p
	return res

def binary(n, digits=20):
	b = bin(n)[2:]
	b = '0' * (digits - len(b)) + b
	return b

def isprime(n):
	if n < 4:
		return True
	if n % 2 == 0:
		return False
	if n % 3 == 0:
		return False
	i = 5
	w = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += w
		w = 6 - w
	return True

def generate_primes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	return prime
factorial_modP = []

def warm_up_fac(MOD):
	global factorial_modP, fac_warmup
	if fac_warmup:
		return
	factorial_modP = [1 for _ in range(fac_warmup_size + 1)]
	for i in range(2, fac_warmup_size):
		factorial_modP[i] = factorial_modP[i - 1] * i % MOD
	fac_warmup = True

def InverseEuler(n, MOD):
	return pow(n, MOD - 2, MOD)

def nCr(n, r, MOD):
	global fac_warmup, factorial_modP
	if not fac_warmup:
		warm_up_fac(MOD)
		fac_warmup = True
	return factorial_modP[n] * (pow(factorial_modP[r], MOD - 2, MOD) * pow(factorial_modP[n - r], MOD - 2, MOD) % MOD) % MOD

def test_print(*args):
	if testingMode:
		print(args)

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

def display_2D_list(li):
	for i in li:
		print(i)

def prefix_sum(li):
	sm = 0
	res = []
	for i in li:
		sm += i
		res.append(sm)
	return res

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))
import heapq, itertools
pq = []
entry_finder = {}
REMOVED = '<removed-task>'

def add_task(task, priority=0):
	if task in entry_finder:
		remove_task(task)
	count = next(counter)
	entry = [priority, count, task]
	entry_finder[task] = entry
	heapq.heappush(pq, entry)

def remove_task(task):
	entry = entry_finder.pop(task)
	entry[-1] = REMOVED

def pop_task():
	while pq:
		(priority, count, task) = heapq.heappop(pq)
		if task is not REMOVED:
			del entry_finder[task]
			return task
	raise KeyError('pop from an empty priority queue')
memory = dict()

def clear_cache():
	global memory
	memory = dict()

def cached_fn(fn, *args):
	global memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result

def ncr(n, r):
	return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))

def binary_serach(i, li):
	fn = lambda x: li[x] - x // i
	x = -1
	b = len(li)
	while b >= 1:
		while b + x < len(li) and fn(b + x) > 0:
			x += b
		b = b // 2
	return x
TestCases = False
testingMode = False
fac_warmup_size = 10 ** 5 + 100
optimiseForReccursion = False
from math import factorial

def main():
	n = get_int()
	li = str(input())
	count = 0
	for i in li:
		if i == '+':
			count += 1
		elif count > 0:
			count -= 1
	print(count)
if TestCases:
	for i in range(get_int()):
		cProfile.run('main()') if testingMode else main()
else:
	(cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()


n = int(input())
u = list(input())
mp = 0
p = 0
for i in range(n):
	if u[i] == '-':
		p -= 1
		mp = min(p, mp)
	else:
		p += 1
print(p - mp)


n = input().strip()
s = input().strip()

def rock(n, s):
	m = 0
	for i in range(len(s)):
		if s[i] == '+':
			m = m + 1
		elif s[i] == '-':
			if m > 0:
				m = m - 1
			elif m == 0:
				m = 0
	return m
print(rock(n, s))


def stonePile(operations):
	current = 0
	for operation in operations:
		if operation == '-' and current > 0:
			current -= 1
		elif operation == '+':
			current += 1
	return current
n = int(input())
operations = input()
print(stonePile(operations))


n = int(input())
s = a = 0
for c in input():
	s += 1 if c == '+' else -1
	a = min(a, s)
print(s - a)


n = int(input())
List = list(input())
plus = 0
minys = 0
ans = 0
for i in List:
	if i == '+':
		ans += 1
	elif ans > 0:
		ans -= 1
print(ans)


n = int(input())
s = input()
a = s.count('+')
b = s.count('-')
minv = 9999999999999999
c = 0
for x in s:
	if x == '+':
		c += 1
	else:
		c -= 1
	minv = min(c, minv)
print(max(-1 * minv, 0) + a - b)


x = int(input())
s = [n for n in input()]
l = 0
for n in s:
	if n == '-' and l != 0:
		l -= 1
	elif n == '+':
		l += 1
print(l)


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


n = int(input())
p = input()
min_prefix = 0
acc = 0
for i in range(n):
	acc += 1 if p[i] == '+' else -1
	min_prefix = min(min_prefix, acc)
print(acc - min_prefix)


from sys import stdin
n = int(stdin.readline().strip())
s = stdin.readline().strip()
ans = 101
for i in range(0, 101):
	x = i
	for j in range(n):
		if s[j] == '-':
			x -= 1
		else:
			x += 1
		if x < 0:
			x = 101
			break
	ans = min(x, ans)
print(ans)


n = int(input())
ar = list(input())
r = 0
for i in ar:
	if i == '+':
		r += 1
	elif r > 0:
		r -= 1
print(max(r, 0))


def main():
	from sys import stdin, stdout

	def read():
		return stdin.readline().rstrip('\n')

	def read_array(sep=None, maxsplit=-1):
		return read().split(sep, maxsplit)

	def read_int():
		return int(read())

	def read_int_array(sep=None, maxsplit=-1):
		return [int(a) for a in read_array(sep, maxsplit)]

	def write(*args, **kwargs):
		sep = kwargs.get('sep', ' ')
		end = kwargs.get('end', '\n')
		stdout.write(sep.join((str(a) for a in args)) + end)

	def write_array(array, **kwargs):
		sep = kwargs.get('sep', ' ')
		end = kwargs.get('end', '\n')
		stdout.write(sep.join((str(a) for a in array)) + end)
	n = read_int()
	s = read()
	stones = 0
	for c in s:
		if c == '+':
			stones += 1
		else:
			stones -= 1
			if stones < 0:
				stones = 0
	write(stones)
main()


n = int(input())
s = input()
minInitialStone = 0
i = 0
for action in s:
	if action == '-':
		i -= 1
		if i < 0 and abs(i) > minInitialStone:
			minInitialStone += 1
	if action == '+':
		i += 1
print(minInitialStone + i)


number = int(input())
order = input()
count = 0
for i in range(number):
	if order[i] == '-':
		if count == 0:
			continue
		count = count - 1
	else:
		count = count + 1
print(count)


n = int(input())
l = list(input())
for j in range(0, 200):
	mb = 1
	cur = j
	for i in range(n):
		if l[i] == '+':
			cur += 1
		else:
			cur -= 1
			if cur < 0:
				mb = 0
	if mb:
		print(cur)
		exit()


t = 1

def solve():
	(cnt, ans) = (0, 0)
	for i in range(n):
		if s[i] == '-':
			cnt += 1
		else:
			ans = max(ans - cnt, 0)
			ans += 1
			cnt = 0
	return max(ans - cnt, 0)
for _ in range(t):
	n = int(input())
	s = input()
	print(solve())


n = int(input())
seq = input()
max_ = n
count = 0
for i in seq:
	if i == '+':
		count += 1
	if i == '-':
		count = max(count - 1, 0)
print(count)


n = int(input())
s = input()
ln = len(s)
sv = 0
for i in s:
	if i == '+':
		sv += 1
	if i == '-' and sv > 0:
		sv -= 1
print(sv)


from math import *
from itertools import *
n = int(input())
s = input()
s = s[::-1]
tot = 0
for i in range(105):
	now = i
	flg = 0
	for j in s:
		if j == '-':
			now += 1
		else:
			now -= 1
		if now < 0:
			flg = 1
			break
	if flg == 0:
		tot = i
		break
print(tot)


n = int(input())
actions = [str(x) for x in str(input())][::-1]

def net_change(actions):
	initial = 0
	prefixes = []
	while actions:
		cur = actions.pop()
		if cur == '+':
			initial += 1
		else:
			initial -= 1
		prefixes.append(int(initial))
	return (prefixes, initial)
answer = net_change(actions)
lowest = min(min(answer[0]), 0)
print(answer[1] - lowest)


n = int(input())
fin = n
for i in input():
	if i == '-' and fin < n:
		fin += 1
	elif i == '+':
		fin -= 1
print(n - fin)


n = int(input())
s = list(input())
cnt_sub = 0
cnt_plus = 0
i = 0
k = 0
while s[i] != '+' and i < n:
	k += 1
	i += 1
	if i == n:
		break
arr = []
for item in s:
	if item == '-':
		k -= 1
	else:
		k += 1
	if k < 0:
		k = 0
print(k)


n = int(input())
res = 0
for ch in input():
	if ch == '+':
		res = res + 1
	elif ch == '-':
		res = res - 1
		if res < 0:
			res = 0
print(res)


x = 10 ** 9 + 7
N = int(input())
S = input()
mini = x
for s in S:
	if s == '+':
		x += 1
	else:
		x -= 1
	mini = min(mini, x)
print(x - mini)


def main():
	n = int(input())
	operations = input()
	remaining = 0
	initial = 0
	sumOp = 0
	subOp = 0
	for op in operations:
		if op == '-':
			subOp += 1
			remaining -= 1
		if op == '+':
			sumOp += 1
			remaining += 1
		if remaining < 0:
			initial += abs(remaining)
			remaining = 0
	print(initial + sumOp - subOp)
main()


n = int(input())
s = input()
if s == '-' * n:
	print(0)
elif s == '+' * n:
	print(len(s))
else:
	inc = 0
	dec = 0
	for i in range(n):
		if s[i] == '+':
			inc += 1
		elif s[i] == '-':
			dec += 1
			if inc < dec:
				inc += 1
	print(inc - dec)


op = int(input())
pile = input()
a = pile[0]
if a == '-':
	stone = 1
else:
	stone = 0
for i in range(op):
	if pile[i] == '+':
		stone += 1
	else:
		stone -= 1
		if stone < 0:
			stone = 0
print(stone)


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


n = int(input())
s = input()
result = count = 0
x = 0
for i in range(n):
	if s[i] == '+':
		count += 1
		x += 1
	else:
		count -= 1
		x -= 1
		if count < 0:
			result += 1
			count += 1
print(result + x)


import sys
sys.stdin.readline()
line = sys.stdin.readline()
base = 0
sum = 0
for c in line:
	if c == '+':
		sum += 1
	elif c == '-':
		sum -= 1
	base = min(sum, base)
sys.stdout.write(f'{-1 * base + sum}')


a = int(input())
n = input()
c = 0
k = 0
d = 0
for b in n:
	if b == '+':
		c = c + 1
		d = d + 1
	if b == '-':
		k = k + 1
		d = d - 1
	if d < 0:
		d = d + 1
if c == 0:
	print(0)
elif k == 0:
	print(c)
else:
	print(d)


num = int(input())
data = input()
mn = 0
cnt = 0
for i in range(num):
	if data[i] == '+':
		cnt += 1
	else:
		cnt -= 1
		mn = min(cnt, mn)
print(cnt - mn)


n = int(input())
stri = input()
count = 0
for i in stri:
	if i == '+':
		count += 1
	elif count == 0 and i == '-':
		pass
	else:
		count -= 1
print(count)


n = int(input())
k = str(input())
s = 0
count = 0
p = 0
m = 0
for i in k:
	if i == '-':
		s = s - 1
		m = m + 1
	if i == '+':
		s = s + 1
		p = p + 1
	if s < 0:
		s = 0
print(s)


def main(n, s):
	if '+' not in s:
		return 0
	if '-' not in s:
		return n
	index = 0
	x = 0
	while x < n:
		if s[x] == '-':
			if index == 0:
				index = index + 1
			index = index - 1
		else:
			index = index + 1
		x = x + 1
	return index

def count(s, index):
	x = 0
	c = 0
	while x < len(s):
		if s[x] == index:
			c = c + 1
		x = x + 1
	return c
n = int(input())
s = input()
a = main(n, s)
print(a)


n = int(input())
op = input()
bile = 0
for i in op:
	if i == '+':
		bile += 1
	else:
		bile -= 1
	if bile < 0:
		bile = 0
print(bile)


def solve(n, s):
	x = 0
	for i in s:
		if i == '-':
			if x > 0:
				x -= 1
		else:
			x += 1
	return max(0, x)

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


n = int(input())
a = input()
(balance, min1) = (0, 0)
for q in a:
	if q == '+':
		balance += 1
	else:
		balance -= 1
	min1 = min(min1, balance)
print(balance - min1)


n = int(input())
a = input()
c = 0
for i in a:
	if i == '-' and c > 0:
		c -= 1
	elif i == '-' and c < 0:
		c = 0
	if i == '+':
		c += 1
print(c)


t = int(input())
a = input()
p = 0
q = 0
li = []
for i in range(t):
	if a[i] == '+':
		p += 1
	if a[i] == '-':
		q -= 1
	z = p + q
	if z < 0:
		li.append(z)
l = len(li)
if l > 0:
	x = min(li)
	c = abs(x)
	k = c + z
	print(k)
if l == 0:
	print(z)


import io
import os
from collections import defaultdict
from sys import stdin, stdout
from math import gcd

def main():
	n = int(input())
	op = input()
	m = 0
	s = 0
	for o in op:
		if o == '-':
			s -= 1
			if s < 0:
				m += 1
				s += 1
		elif o == '+':
			s += 1
	print(s)
main()


n = int(input())
ops = input().strip()
begin = 0
for op in ops:
	if op == '-':
		begin -= 1
	elif op == '+':
		begin += 1
	begin = max(begin, 0)
print(begin)


n = int(input())
a = list(str(input()))
d = 0
for i in range(n):
	if a[i] == '+':
		d += 1
	else:
		d -= 1
	if d < 0:
		d = 0
print(d)


k = input()
l = 0
str = input()
for c in str:
	if c == '+':
		l += 1
	else:
		if l == 0:
			l += 1
		l -= 1
print(l)


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


import sys
import collections
import math
import heapq
from operator import itemgetter

def getint():
	return int(input())

def getints():
	return [int(x) for x in input().split(' ')]
n = getint()
s = input()
result = 0
sumCount = 0
minDelta = 0
for char in s:
	if char == '-':
		sumCount -= 1
	else:
		sumCount += 1
	if sumCount < 0:
		minDelta = max(minDelta, -sumCount)
result = max(0, sumCount + minDelta)
print(str(result))


n = int(input())
d = input()
cnt1 = 0
for i in d:
	if i == '-' and cnt1 > 0:
		cnt1 = cnt1 - 1
	if i == '+':
		cnt1 = cnt1 + 1
print(cnt1)


n = int(input())
text = input()
(nract, nrinit) = (0, 0)
for i in range(n):
	if text[i] == '+':
		nract += 1
	elif nract == 0:
		nrinit += 1
	else:
		nract -= 1
print(nrinit - len(text.replace('+', '')) + len(text.replace('-', '')))


a = int(input())
b = input()
s = 0
k = 0
for i in range(a):
	if b[i] == '-' and k > 0:
		if s > 0:
			s -= 1
	elif b[i] == '+':
		k += 1
		s += 1
print(s)


input()
count = 0
for c in input():
	if c == '+':
		count += 1
	elif count:
		count -= 1
print(count)


n = int(input())
l = [x for x in input()]
ans = 0
for i in l:
	if i == '+':
		ans += 1
	if i == '-':
		if ans == 0:
			continue
		ans -= 1
print(max(0, ans))


n = int(input())
mp = {'+': 1, '-': -1}
a = list(map(lambda x: mp[x], list(input())))
mn = 0
sum = 0
for el in a:
	sum += el
	mn = min(mn, sum)
print(sum - mn)


def stones_after(n, s):
	for i in s:
		if i == '-':
			n -= 1
		else:
			n += 1
		if n < 0:
			return -1
	return n
n = int(input().strip())
s = input().strip()
ans = 99999999
for i in range(n + 1):
	stones = stones_after(i, s)
	if stones != -1:
		ans = min(ans, stones)
print(ans)


n = int(input())
s = input().strip()
ct = 0
m = 0
ans = 10000000000000000
for i in range(n):
	if s[i] == '-':
		ct -= 1
		m = min(m, ct)
	else:
		ct += 1
ans = abs(m)
for i in range(n):
	if s[i] == '-':
		ans -= 1
	else:
		ans += 1
print(ans)


def main():
	n = int(input())
	s = str(input())
	count = 0
	for op in s:
		if op == '+':
			count += 1
		elif count > 0:
			count -= 1
	print(count)
main()


n = int(input())
s = input()
print(max([sum([1 if k == '+' else -1 for k in s[j:]]) for j in range(n - 1, -1, -1)] + [0]))


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


n = int(input())
s = str(input())
pin = 0
for x in s:
	if x == '-' and pin > 0:
		pin = pin - 1
	elif x == '+':
		pin = pin + 1
	if pin < 0:
		pin = 0
print(pin)


input()
k = 0
for ch in input():
	if ch == '+':
		k += 1
	elif k:
		k -= 1
print(k)


n = int(input())
s = input()
for i in range(101):
	for j in range(n):
		if s[j] == '-':
			i -= 1
		else:
			i += 1
		if i < 0:
			break
	if i >= 0 and j == n - 1:
		print(i)
		break


n = int(input())
a = str(input())
ans = 0
for i in a:
	if i == '+':
		ans += 1
	elif ans != 0:
		ans -= 1
print(ans)


n = int(input())
s = input().strip()
t = 0
minn = 10 ** 100
for i in s:
	if i == '+':
		t += 1
	else:
		t -= 1
	minn = min(minn, t)
t = max(0, -minn)
for i in s:
	if i == '+':
		t += 1
	else:
		t -= 1
print(t)


input()
a = input()
c = 0
for i in a:
	if i == '-':
		c -= 1
		if c < 0:
			c = 0
	else:
		c += 1
print(c)


n = int(input())
opr = input()
opr = list(opr)
x = 0
min = 0
for i in range(n):
	if opr[i] == '+':
		x += 1
	else:
		x -= 1
	if min > x:
		min = x
print(x - min)


n = int(input())
s = input()
minim = n
maxim = 0
for ch in s:
	if ch == '-':
		n -= 1
	else:
		n += 1
	minim = min(minim, n)
print(n - minim)


n = int(input())
s = input()
start = 0
delt = 0
pl = 0
mi = 0
for k in s:
	if k == '+':
		delt += 1
		pl += 1
	else:
		delt -= 1
		mi += 1
	start = min(delt, start)
print(-start + pl - mi)


n = int(input())
n1 = 0
pm = list(input())
for i in pm:
	if i == '-':
		n1 -= 1
		if n1 < 0:
			n1 += 1
	if i == '+':
		n1 += 1
print(n1)


n = int(input())
a = input()
a = list(a)
s = 0
for i in range(0, n):
	if a[i] == '+':
		s += 1
	else:
		s -= 1
	if s < 0:
		s = 0
print(s)


n = int(input())
plus = 0
minus = 0
temp = 0
for i in input():
	if i == '-':
		temp -= 1
		if temp < 0:
			temp = 0
	if i == '+':
		temp += 1
print(temp)


n = int(input())
input_str = str(input())
lst = []
for i in range(n):
	if input_str[i] == '-':
		lst.append(-1)
	elif input_str[i] == '+':
		lst.append(1)
start_num = 0
factor = False
while factor == False:
	pending_num = start_num
	for i in range(len(lst)):
		pending_num += lst[i]
		if pending_num < 0:
			start_num += 1
			break
		elif i + 1 == len(lst):
			factor = True
			print(pending_num)


n = int(input())
a = input()
a = a.lstrip('-')
ans = 0
for x in a:
	if x == '+':
		ans += 1
	elif ans > 0:
		ans -= 1
print(ans) if ans > 0 else print(0)


n = int(input())
a = input()
count = 0
for i in range(n):
	if count > 0 and a[i] == '-':
		count -= 1
	elif a[i] == '+':
		count += 1
print(count)


n = int(input())
ar = list(input())
ptr = 0
arr = []
for k in ar:
	if k == '-':
		arr.append(ptr - 1)
		ptr -= 1
	else:
		arr.append(ptr + 1)
		ptr += 1
if min(arr) < 0:
	print(arr[-1] - min(arr))
else:
	print(arr[-1])


n = int(input())
ops = input()
lowest = 0
current = 0
for i in ops:
	if i == '-':
		current -= 1
		if current < lowest:
			lowest = current
	else:
		current += 1
print(current - lowest)


ope = int(input())
count = 0
s = input()
for i in range(len(s)):
	if s[i] == '+':
		count += 1
	elif count > 0:
		count -= 1
print(count)


a = int(input())
s = input()
rok = 0
for i in s:
	if i == '+':
		rok += 1
	if i == '-':
		rok += -1
	if rok < 0:
		rok += 1
print(rok)


(_, s) = (input(), input())
x = 0
start = 0
for c in s:
	if c is '+':
		x += 1
	elif c is '-':
		if x <= 0:
			start += 1
		else:
			x -= 1
print(x)


n = int(input())
inp = input()
cnt = 0
for i in inp:
	if i == '-':
		cnt -= 1
		if cnt < 0:
			cnt = 0
	else:
		cnt += 1
print(cnt)


def vasya(n, s):
	k = 0
	for i in range(n):
		if s[i] == '+':
			k = k + 1
		elif k == 0:
			k = 0
		else:
			k = k - 1
	return k
n = int(input())
s = str(input())
print(vasya(n, s))


a = int(input())
b = input()
s = 0
for i in b:
	if i == '-':
		s -= 1
		if s < 0:
			s = 0
	else:
		s += 1
print(s)


n = int(input())
op = input()
count = 0
start = 0
for i in range(n):
	if op[i] == '+':
		count += 1
	else:
		count -= 1
	start = max(-count, start)
print(start + count)


input()
SUM = 0
for i in input():
	SUM += 1 if i == '+' else 0 if SUM == 0 else -1
print(SUM)


n = int(input())
nr = 0
s = [None] * n
s = input()
if s[0] == '-':
	nr = 1
for i in range(0, n):
	if s[i] == '-':
		nr = nr - 1
	else:
		nr = nr + 1
	if nr < 0:
		nr = nr + 1
print(nr)


n = int(input())
x = input()
s = 0
while x[0] != '+':
	x = x[1:]
	if len(x) == 0:
		break
for i in range(len(x)):
	if x[i] == '+':
		s += 1
	else:
		s -= 1
		if s == -1:
			s = 0
print(s)


from sys import stdin, setrecursionlimit
from bisect import bisect_right
setrecursionlimit(15000)
n = int(stdin.readline().strip())
string = list(stdin.readline().strip())
net = 0
for i in range(len(string)):
	if string[i] == '-':
		net -= 1
	else:
		net += 1
	if net < 0:
		net = 0
print(net)


from sys import stdin, stdout
n = int(stdin.readline())
s = stdin.readline()
s = s[:-1]
init = 0
count = m = 0
for i in s:
	if i == '-':
		count -= 1
		if count < m:
			m = count
	else:
		count += 1
init = abs(m)
for i in s:
	if i == '-':
		init -= 1
	else:
		init += 1
stdout.write(str(init) + '\n')


import sys
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *
n = int(input())
s = input()
count = 0
for i in list(s):
	if i == '+':
		count += 1
	elif count > 0:
		count -= 1
print(count)


def rahul(word):
	return [char for char in word]
a = int(input())
b = rahul(input())
r = 0
s = 0
while r < a:
	if b[r] == '+':
		s = s + 1
	elif b[r] == '-' and s > 0:
		s = s - 1
	r = r + 1
print(s)


def main():
	d = int(input())
	c = input()
	mv = 0
	cur = 0
	for d in c:
		if d == '-':
			cur -= 1
			mv = min(cur, mv)
		else:
			cur += 1
			mv = min(cur, mv)
	print(max(0 - mv, 0) + cur)
main()


n = int(input())
s = input()
count = 0
for c in s:
	if c == '+':
		count += 1
	elif c == '-' and count == 0:
		continue
	else:
		count -= 1
print(count)


t = int(input())
ip = input()
counter = 0
for i in range(t):
	if ip[i] == '+':
		counter += 1
	elif counter == 0:
		counter = 0
	else:
		counter = counter - 1
print(counter)


n = input()
operations = input()
times = 0
for i in list(operations):
	if i == '-' and times > 0:
		times -= 1
	elif i == '+':
		times += 1
print(times)


import sys
input = sys.stdin.readline
n = int(input())
s = input()
ans = 0
for i in range(n):
	if s[i] == '-':
		ans -= 1
		if ans == -1:
			ans = 0
	else:
		ans += 1
print(ans)


n = int(input())
numList = input()
found = False
count = 0
for i in numList:
	if i == '+':
		count += 1
	elif i == '-' and count > 0:
		count -= 1
print(count)


n = int(input())
op = input()
r = 0
for i in op:
	if i == '+':
		r += 1
	elif r > 0:
		r -= 1
print(r)