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