#include <bits/stdc++.h>
using namespace std;
bool test = true;
int tt = 1;
struct fio {
  fio() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(10);
  }
} fio;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    int cnt = 0;
    vector<int> v;
    for (auto ele : s) {
      if (ele == '0') {
        v.push_back(cnt);
        cnt = 0;
      } else {
        cnt++;
      }
    }
    v.push_back(cnt);
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());
    int ans = 0;
    for (int i = 0; i < v.size(); i += 2) {
      ans += v[i];
    }
    cout << ans << "\n";
  }
  return 0;
}
