#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int tc;
  cin >> tc;
  while (tc--) {
    string s;
    cin >> s;
    int mn = 200, mx = 0;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == '1' && i < mn) mn = i;
      if (s[i] == '1' && i > mx) mx = i;
    }
    int ans = 0;
    for (int i = mn; i <= mx; i++) ans += s[i] == '0';
    cout << ans << endl;
  }
}
