#include <bits/stdc++.h>
using namespace std;
char s[211];
int t, res, ss;
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%s", s + 1);
    int l, r;
    ss = strlen(s + 1);
    for (l = 1; l <= ss; l++)
      if (s[l] == '1') break;
    for (r = ss; r >= 1; r--)
      if (s[r] == '1') break;
    res = 0;
    for (int i = l; i <= r; i++) res += (s[i] == '0');
    printf("%d\n", res);
  }
  return 0;
}
