#include <bits/stdc++.h>
using namespace std;
int a[101];
int main() {
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    int j = 0, sc = 0, dem1 = 0;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == '1')
        dem1++;
      else {
        j++;
        a[j] = dem1;
        dem1 = 0;
      }
    }
    if (dem1) j++, a[j] = dem1;
    sort(a + 1, a + 1 + j, greater<int>());
    for (int i = 1; i <= j; i++)
      if (i % 2 == 1) sc += a[i];
    cout << sc << endl;
  }
}
