#include <bits/stdc++.h>
using namespace std;
constexpr long long INF = 1e15;
const long long MAXN = 2e5 + 10;
long long first;
void run() {
  string s;
  cin >> s;
  long long n = s.size();
  vector<long long> nextz(n);
  nextz[n - 1] = (s[n - 1] == '1' ? n - 1 : n);
  for (long long i = n - 2; i >= 0; i--) {
    nextz[i] = (s[i] == '1' ? i : nextz[i + 1]);
  }
  long long ans = 0;
  for (long long i = 0; i < s.size(); i++) {
    long long cr = 0;
    for (long long j = nextz[i]; j < min(nextz[i] + 32, (long long)s.size());
         j++) {
      cr *= 2;
      cr += s[j] - '0';
      if (cr == j - i + 1) {
        ans++;
      }
    }
  }
  cout << ans << '\n';
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long t = 1;
  cin >> t;
  while (t--) {
    run();
  }
  return 0;
}
