#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, count = 0, sum = 0;
  ;
  cin >> t;
  while (t--) {
    string str;
    cin >> str;
    vector<int> vec;
    for (int i = 0; i < str.size();) {
      if (str[i] == '1') {
        while (str[i] == '1') {
          count++;
          i++;
        }
        vec.push_back(count);
        count = 0;
      } else {
        i++;
      }
    }
    sort(vec.begin(), vec.end(), greater<int>());
    for (int j = 0; j < vec.size(); j = j + 2) {
      sum = sum + vec[j];
    }
    cout << sum << endl;
    sum = 0;
  }
}
