#include <bits/stdc++.h>
using namespace std;
const long long int inf = 1e9 + 7;
void solve();
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout << fixed;
  cout << setprecision(10);
  long long int t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
bool comp(long long int a, long long int b) { return a > b; }
void solve() {
  long long int i, n, x = 0, ans = 0;
  string s;
  cin >> s;
  vector<long long int> v;
  n = s.length();
  for (i = 0; i < n; i++) {
    if (s[i] == '0') {
      v.push_back(x);
      x = 0;
    } else
      x++;
  }
  v.push_back(x);
  sort(v.begin(), v.end(), comp);
  for (auto itr = v.begin(); itr < v.end(); itr += 2) ans += *itr;
  cout << ans << endl;
}
