#include #include #include #include #include using namespace std; char s[100000 + 1]; int main() { int tests, test = 1; for (assert(scanf("%d", &tests) == 1 && 1 <= tests && tests <= 7); test <= tests; ++ test) { assert(scanf("%s", s) == 1); int n = strlen(s); assert(1 <= n && n <= 100000); for (int i = 0; i < n; ++ i) { assert(s[i] == '+' || s[i] == '-'); } int plan1 = 0, plan2 = 0; for (int i = 0; i < n; ++ i) { plan1 += (s[i] == '+') == (i & 1); plan2 += (s[i] == '-') == (i & 1); } printf("%d\n", min(plan1, plan2)); } return 0; }