public void solve() throws IOException {
    int T = nextInt();
    for (int t = 1; t <= T; t++) {
      char[] S = nextLine().toCharArray();
      int flips = 0;
      for (int i = S.length - 1; i >= 0; i--) {
        if (S[i] != '+') {
          int start = 0;
          while (S[start] == '+') {
            start++;
          }
          if (start > 0) {
            flips++;
            flip(S, start - 1);
          }
          flips++;
          flip(S, i);
        }
      }
      out.format("Case #%d: %d%n", t, flips);
    }
  }