#include <bits/stdc++.h>
using namespace std;
bool check(string s, int n) {
  int val = 0;
  int cur = 0;
  for (int i = s.length() - 1; i >= 0; i--) {
    if (s[i] == '1') {
      val += (1 << cur);
    }
    cur++;
  }
  if (val == n)
    return true;
  else
    return false;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int T;
  cin >> T;
  while (T--) {
    string s;
    cin >> s;
    int n = s.length();
    vector<int> v(n + 1);
    v[n] = -1;
    for (int i = n - 1; i >= 0; i--) {
      if (s[i] == '1')
        v[i] = i;
      else
        v[i] = v[i + 1];
    }
    long long ans = 0;
    for (int i = 0; i < n; i++) {
      int p = v[i];
      if (p == -1) break;
      int cur = p - i;
      string t = "";
      for (int j = p; j < min(p + 20, n); j++) {
        cur++;
        t += s[j];
        if (check(t, cur)) ans++;
      }
    }
    cout << ans << '\n';
  }
  return 0;
}
