#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int n;
char s[N];
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    scanf("%s", s + 1);
    n = strlen(s + 1);
    int beg = 1, end = n;
    while (beg <= n && s[beg] == '0') beg++;
    while (end >= 1 && s[end] == '0') end--;
    int ans = 0;
    for (int i = beg; i <= end; i++)
      if (s[i] == '0') ans++;
    printf("%d\n", ans);
  }
  return 0;
}
