#include <bits/stdc++.h>
long long n, i, j, h, k, t, d, m, test, a[200005], b[200005], f[2000005], res;
using namespace std;
string s;
int main() {
  cin >> test;
  for (h = 1; h <= test; h++) {
    cin >> s;
    k = 0;
    res = 0;
    m = 0;
    for (i = 0; i <= s.length(); i++) f[i] = 1e9;
    for (i = 0; i < s.length(); i++) {
      if (s[i] == '+')
        k++;
      else
        k--;
      if (k < 0) {
        res += 2 * (i + 1) - m;
        m = i + 1;
        k++;
      }
    }
    cout << res + s.length() - m << endl;
  }
}
