#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  cin >> s;
  long long n = s.size();
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    a[i] = s[i] - '0';
  }
  vector<long long> p(n);
  p[0] = (a[0] == 0 ? 1 : 0);
  for (long long i = 1; i < n; i++) {
    p[i] = (a[i] == 0 ? p[i - 1] + 1 : 0);
  }
  long long cnt = 0;
  for (long long i = 0; i < n; i++) {
    if (a[i] == 0) {
      continue;
    }
    long long num = 0;
    for (long long j = i; j < i + min(25LL, n - i); j++) {
      num = num * 2LL + a[j];
      if (num == j - i + 1) {
        cnt++;
      } else {
        if (num > j - i + 1) {
          if (i > 0 && p[i - 1] >= num - j + i - 1) {
            cnt++;
          }
        }
      }
    }
  }
  cout << cnt << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
