#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
int main() {
  long long int t, n, i, j, m, d, k, q, y, z, l, r, a, b, c;
  cin >> t;
  while (t--) {
    string str;
    cin >> str;
    n = str.length();
    z = 0;
    int p = 0;
    m = 0;
    int x = 0;
    for (i = 0; i < (n); ++i) {
      z++;
      if (str[i] == '+')
        p++;
      else
        m++;
      if (x + p - m < 0) {
        x++;
        z += (i + 1);
      }
    }
    cout << z << "\n";
  }
}
