#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    long long int n = s.length();
    int i = 0;
    for (i = 0; i < n; i++) {
      if (s[i] == '0')
        s[i] = '2';
      else
        break;
    }
    for (i = n - 1; i >= 0; i--) {
      if (s[i] == '0')
        s[i] = '2';
      else
        break;
    }
    long long int c = 0;
    for (int i = 0; i < n; i++)
      if (s[i] == '0') c++;
    cout << c << endl;
  }
}
