#include using namespace std; using ll = long long; void solve(){ int N; cin >> N; int cnt0 = 0, cnt1 = 0; string S; cin >> S; for(auto c: S){ if(c == '+') ++cnt1; } int ans = cnt0 + cnt1; for(auto c: S){ ans = max(ans, cnt0 + cnt1); if(c == '-') ++cnt0; if(c == '+') --cnt1; if(c == '0') ans = max(ans, cnt1 + cnt0 + 1); ans = max(ans, cnt0 + cnt1); } cout << ans << "\n"; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cout << setprecision(10) << fixed; int T; T = 1; //cin >> T; for(;T--;) solve(); }