#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
const long long N = 1e5 + 5;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long te;
  cin >> te;
  while (te--) {
    string s;
    cin >> s;
    long long n = (long long)s.size();
    long long ans = 0, z = 0;
    for (long long i = 0; i < n; i++) {
      if (s[i] == '0') {
        z++;
        continue;
      }
      long long cur = 0;
      for (long long j = i; j < min(i + 20, n); j++) {
        cur = 2 * cur + (s[j] - '0');
        if (j - i + 1 + z >= cur)
          ans++;
        else
          break;
      }
      z = 0;
    }
    cout << ans << "\n";
  }
  return 0;
}
