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