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