#include <bits/stdc++.h>
using namespace std;
const int N = 5e4 + 10;
const int inf = 0x7fffffff;
string a;
int num[105];
bool cmp(int a, int b) { return a > b; }
int main() {
  int t;
  cin >> t;
  while (t--) {
    cin >> a;
    int cnt = 0, ans = 0;
    for (int i = 0; i < a.length(); i++) {
      if (a[i] == '1') {
        ans++;
      } else if (a[i] == '0' && ans) {
        num[cnt++] = ans;
        ans = 0;
      }
    }
    if (ans) num[cnt++] = ans;
    ans = 0;
    sort(num, num + cnt, cmp);
    for (int i = 0; i < cnt; i += 2) ans += num[i];
    cout << ans << endl;
  }
  return 0;
}
