#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n; string s; cin >> n >> s; vector a(n); int cur = 2; for(int i = 0; i < n; i++){ if(s[i] == '+') a[i] = cur++; } cur = -2; for(int i = n - 1; i >= 0; i--){ if(s[i] == '-') a[i] = cur--; } vector b; for(int i = 0; i < n; i++){ int p = lower_bound(b.begin(), b.end(), a[i]) - b.begin(); if(p == b.size()) b.emplace_back(a[i]); else b[p] = a[i]; } cout << b.size() << '\n'; }