#include <bits/stdc++.h>
using namespace std;
long long int n, x;
string s;
long long int twos[25];
long long int vis[200005];
int main() {
  int t;
  scanf("%d", &t);
  twos[0] = 1;
  for (long long int ii = 1; ii <= 24; ii++) {
    twos[ii] = twos[ii - 1] * 2;
  }
  while (t--) {
    long long int i, j, k, ctr = 0, ctr1 = 0;
    cin >> s;
    n = s.length();
    vector<long long int> v;
    fill(vis, vis + n + 1, 0);
    for (i = n - 1; i >= 0;) {
      if (s[i] == '1') {
        ctr = 0;
        j = i - 1;
        v.push_back(i);
        while (j >= 0 && s[j] == '0') {
          ctr++;
          j--;
        }
        vis[i] = ctr;
        i = j;
      } else {
        i--;
      }
    }
    ctr = 0;
    for (i = 0; i < v.size(); i++) {
      ctr = 0;
      for (j = v[i]; j < n; j++) {
        if (j - v[i] >= 24) {
          break;
        }
        if (s[j] == '1') {
          ctr *= 2;
          ctr++;
        } else {
          ctr *= 2;
        }
        if (ctr > n) {
          break;
        }
        if (vis[v[i]] >= ctr - (j - v[i] + 1)) {
          ctr1++;
        }
      }
    }
    printf("%lld\n", ctr1);
  }
  return 0;
}
