#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7ll, MAXN = 200069, INF = 2e18, MOD2 = 998244353;
void Master() {
  string s;
  cin >> s;
  int n = s.size();
  const int MAXB = 17;
  int ans = 0;
  int Le[n];
  for (int i = 0; i < n; ++i) {
    if (s[i] == '1') {
      Le[i] = i;
    } else {
      Le[i] = (i ? Le[i - 1] : -1);
    }
  }
  for (int i = 0; i < n; ++i) {
    int l = i, val = 0;
    while (l >= 0 and i - l < 20) {
      if (s[l] == '1') {
        val += 1LL << (i - l);
        if (val <= i - (l ? Le[l - 1] : -1)) {
          ++ans;
        }
      }
      --l;
    }
  }
  cout << ans << '\n';
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int tt = 1;
  cin >> tt;
  for (int tc = 1; tc <= tt; ++tc) {
    Master();
  }
  return 0;
}
