from collections.abc import Iterable from enum import IntEnum, auto from functools import cache class E(IntEnum): S = 0 NEG = auto() ZERO = auto() POS = auto() def nexts(self): match self: case E.S: return [E.NEG, E.ZERO, E.POS] case E.NEG: return [E.NEG, E.ZERO, E.POS] case E.ZERO: return [E.POS] case E.POS: return [E.POS] assert False @staticmethod @cache def states(): res = [] for fm in E: for to in fm.nexts(): res.append((fm, to)) return res def state_dp(xs: Iterable, op, e, init: dict, *, is_reset=True): dp = [e] * len(E) for k, v in init.items(): dp[k] = v for x in xs: pp = [e] * len(E) if is_reset else dp.copy() dp, pp = pp, dp for fm, to in E.states(): if not is_valid(to, pp[fm], x): continue dp[to] = op(to, dp[to], fm, pp[fm], x) return dp def is_valid(to: E, fm_v, v) -> bool: return True def is_match(to: E, v): match to: case E.NEG: return v == '-' case E.ZERO: return v == '0' case E.POS: return v == '+' return False def op(to: E, to_v, fm: E, fm_v, v): score = 1 if is_match(to, v) else 0 return max(to_v, fm_v + score) N = int(input()) S = input() dp = state_dp(S, op, 0, {E.S: 0}) ans = max(dp[x] for x in [E.NEG, E.ZERO, E.POS]) print(ans)