#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  long long t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    long long n = s.size(), ans = 0;
    long long z[n], k = 0;
    z[0] = 0;
    for (long long i = 1; i < n; i++) {
      if (s[i - 1] == '0')
        k++;
      else
        k = 0;
      z[i] = k;
    }
    for (long long i = 0; i < n; i++) {
      if (s[i] == '1') {
        long long x = 0;
        for (long long j = i; j < min(n, i + 20); j++) {
          x = (x * 2) + s[j] - '0';
          if (j - i + 1 + z[i] >= x) ans++;
        }
      }
    }
    cout << ans << endl;
  }
}
