#include <bits/stdc++.h>
const int mod = 1e9 + 7;
using namespace std;
const int maxn = 105;
char a[maxn];
int shu[maxn];
int main() {
  int t, i, sum;
  scanf("%d", &t);
  while (t--) {
    memset(a, 0, sizeof(a));
    getchar();
    scanf("%s", a);
    int len = strlen(a);
    a[len] = '0';
    int j, k = 1;
    for (i = 0; i <= len; i++) {
      if (a[i] == '1') {
        sum = 0;
        for (j = i; j <= len; j++) {
          if (a[j] == '1') {
            sum++;
          } else {
            shu[k] = sum;
            k++;
            i += sum;
            break;
          }
        }
      }
    }
    sort(shu + 1, shu + k);
    int he = 0;
    for (i = k - 1; i >= 1; i -= 2) {
      he += shu[i];
    }
    printf("%d\n", he);
  }
  return 0;
}
