#include using namespace std; using ll = long long; const ll mod = 1e9 + 7; const int N = 200005; const int INF = 0x3f3f3f3f; int main() { int n; string s; cin >> n >> s; vector vec; int p1 = -INF, p2 = 1; for (int i = 0; i < n; i++) { if (s[i] == '-') { vec.push_back(p1); p1++; } else if (s[i] == '+') { vec.push_back(p2); p2++; } else { vec.push_back(0); } } auto end = vec.begin(); for (auto x : vec) { auto it = lower_bound(vec.begin(), end, x); *it = x; if (it == end) end++; } cout << end - vec.begin() << "\n"; return 0; }