#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const ll mod = 1000000007;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  ll t;
  cin >> t;
  while (t--) {
    string second;
    cin >> second;
    ll n = (ll)second.size(), zero[n], cur, num, cnt = 0, ans = 0;
    for (ll i = 0; i < n; i++) {
      zero[i] = cnt;
      if (second[i] == '0')
        cnt++;
      else
        cnt = 0;
    }
    for (ll i = 0; i < n; i++) {
      if (second[i] == '0') continue;
      cur = i, num = 0;
      ll dig = 0;
      while (cur < n) {
        num = num * 2 + (second[cur++] - '0');
        dig++;
        if (num > 2e5) break;
        ans += (zero[i] + dig >= num);
      }
    }
    cout << ans << "\n";
  }
  return 0;
}
