#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 100;
string s[MAX_N];
int div(int n) {
  int ans = 0;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) ans += 2;
  }
  int u = sqrt(n);
  if (u * u == n) ans--;
  return ans;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    vector<int> v;
    int c = 0;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == '1') {
        c++;
      }
      if (s[i] == '0' || i == s.size() - 1) {
        v.push_back(c);
        c = 0;
      }
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    int sum = 0;
    for (int i = 0; i < v.size(); i += 2) {
      sum = sum + v[i];
    }
    cout << sum << endl;
  }
  return 0;
}
