n = int(input()) S = list(input()) tot = 0 mi = False ma = 0 ind = -1 for i, s in enumerate(S): if s == "+": tot += 1 elif s == "-": tot -= 1 else: tot += 1 if tot < 0: if not mi: mi = True ind = i if mi: ma = max(ma, tot) if not mi: print(0) exit() for i in range(ind - 1, -1, -1): if S[i] == "?": if ma > 0: S[i] = "-" ma -= 1 else: S[i] = "+" if ma > 0: print(2) exit() tot = 0 for i in range(ind): if S[i] == "+": tot += 1 else: tot -= 1 if tot < 0: print(2) exit() print(1)