#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    string str;
    cin >> str;
    long int a[100], k = 0, c = 0, sum = 0;
    for (int i = 0; i < str.size(); i++) {
      if (str[i] == '1') {
        c = 0;
        while (str[i] == '1') {
          c++;
          i++;
        }
        i--;
        a[k] = c;
        k++;
      }
    }
    sort(a, a + k);
    for (int i = k - 1; i >= 0; i -= 2) {
      sum += a[i];
    }
    cout << sum << endl;
  }
}
