#include <bits/stdc++.h>
using namespace std;
void solution() {
  char s[100];
  scanf("%s", s);
  int i, count = 0;
  vector<int> bunch;
  for (i = 0; s[i] != '\0'; i++) {
    if (count && s[i] == '0') {
      bunch.push_back(count);
      count = 0;
    } else if (s[i] == '1') {
      count += 1;
      if (s[i + 1] == '\0') bunch.push_back(count);
    }
  }
  sort(bunch.rbegin(), bunch.rend());
  int l = bunch.size(), a = 0, b = 0;
  for (i = 0; i < l; i++) {
    if (i & 1)
      b += bunch[i];
    else
      a += bunch[i];
  }
  printf("%d\n", a);
  return;
}
int main() {
  int t = 1;
  scanf("%d", &t);
  while (t--) solution();
  return 0;
}
