#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, t, j, i, h, k = 1, q = 0, w, s = 0, flag = 0;
  char a[105];
  cin >> n;
  for (i = 1; i <= n; i++) {
    s = 0;
    k = 1;
    scanf("%s", a);
    t = strlen(a);
    for (j = 0; j < t; j++) {
      if (a[j] == '1') {
        k++;
        if (k == 2) q = j;
        if (k > 2) {
          s += j - q - 1;
          q = j;
        }
      }
    }
    cout << s << endl;
  }
}
