#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    int len = s.size();
    vector<int> cz(len);
    int cur = 0;
    for (int i = 0; i < len; ++i) {
      if (s[i] == '1') {
        cz[i] = 0;
        cur = 0;
        continue;
      }
      cur++;
      cz[i] = cur;
    }
    int count = 0;
    for (int r = (0); r < (len); r++) {
      long long sum = 0;
      for (int l = r; l >= 0 && (r - l) < 18; --l) {
        if (s[l] == '0') continue;
        if (s[l] == '1') sum += 1 << (r - l);
        if (sum >= r - l + 1) {
          if (r - l + 1 + (l - 1 >= 0 ? cz[l - 1] : 0) >= sum) count++;
        }
      }
    }
    cout << count << endl;
  }
}
