#include <bits/stdc++.h>
using namespace std;
template <class T>
bool umin(T &a, T b) {
  return a > b ? (a = b, true) : false;
}
template <class T>
bool umax(T &a, T b) {
  return a < b ? (a = b, true) : false;
}
const long long inf = 1e18;
const long long N = 2e5 + 10;
void solve(long long tc) {
  string s;
  cin >> s;
  long long len = 0, n = (long long)s.size(), ans = 0;
  for (long long i = 0; i < n; i++) {
    if (s[i] == '0')
      len++;
    else {
      long long res = 0;
      for (long long j = i; j < n; j++) {
        res = res * 2 + (s[j] - '0');
        len++;
        if (res <= len)
          ans++;
        else
          break;
      }
      len = 0;
    }
  }
  cout << ans << endl;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  cin >> t;
  for (long long i = 1; i <= t; i++) solve(t);
  return 0;
}
