#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  cin >> s;
  int n = int(s.size());
  vector<int> v;
  for (int i = 0; i < n; ++i) {
    if (s[i] == '0') continue;
    int cnt = 0;
    if (s[i] == '1')
      while (i < n && s[i] == '1') ++cnt, ++i;
    v.push_back(cnt);
  }
  sort(begin(v), end(v));
  reverse(begin(v), end(v));
  int ans = 0;
  for (int i = 0; i < int(v.size()); i += 2) {
    ans += v[i];
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
}
