#include using namespace std; using ll = long long; int main() { int n; string s; cin >> n >> s; char p = '+'; int x = 0, y = 0, r = 0; s.push_back('+'); for (int i = 0; i <= n; i++) { if (s[i] != '-') { if (x < 0) { x += (y - x) * 2; r++; y = 0; } x++; y = max(y, x); p = '+'; } else { x--; p = '-'; } } cout << r << endl; return 0; }