#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int i, j, n, k, m, t, x = 0, y, sum = 0, maxx;
  string s;
  cin >> t;
  for (j = 0; j < t; j++) {
    cin >> s;
    long long c = 0, ans = 0;
    vector<long long> v;
    for (i = 0; i < s.length(); i++) {
      if (s[i] == '1')
        c++;
      else {
        v.push_back(c);
        c = 0;
      }
    }
    v.push_back(c);
    sort((v).begin(), (v).end());
    reverse((v).begin(), (v).end());
    for (i = 0; i < v.size(); i += 2) ans += v[i];
    cout << ans << "\n";
  }
}
