#include <bits/stdc++.h>
int main() {
  int t, l, i, j, k, m, a, b, c;
  char s[101];
  scanf("%d", &t);
  while (t--) {
    c = 0;
    scanf("%s ", &s);
    l = strlen(s);
    for (j = 0; j < l; j++) {
      if (s[j] == '0') {
        a = j;
      } else if (s[0] == '1') {
        a = 0;
        break;
      } else {
        break;
      }
    }
    for (k = l - 1; k >= 0; k--) {
      if (s[k] == '0') {
        b = k;
      } else if (s[l - 1] == '1') {
        b = l;
        break;
      } else {
        break;
      }
    }
    for (m = a + 1; m < b; m++) {
      if (s[m] == '0') {
        c = c + 1;
      }
    }
    printf("%d\n", c);
  }
  return 0;
}
