#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, r, c;
  string s;
  cin >> t;
  while (t--) {
    cin >> s;
    long long int l = s.length();
    r = 0;
    c = 0;
    for (long long int i = 0; i < l; i++) {
      if (s[i] == '+')
        c = c + 1;
      else
        c = c - 1;
      if (c < 0) {
        c = 0;
        r = r + (i + 1);
      }
    }
    cout << (r + l) << "\n";
  }
  return 0;
}
