#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  unordered_map<int, int> mp;
  for (int tt = 0; tt < t; tt++) {
    mp.clear();
    string s;
    cin >> s;
    int key = 1;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == '1')
        mp[key]++;
      else
        key++;
    }
    if (mp.empty())
      cout << 0 << "\n";
    else {
      int ss[101];
      int l = 0;
      for (auto x : mp) {
        ss[l] = x.second;
        l++;
      }
      sort(ss, ss + l, greater<int>());
      int sum = 0;
      for (int i = 0; i < l; i += 2) {
        sum += ss[i];
      }
      cout << sum << "\n";
    }
  }
  return 0;
}
