#include <bits/stdc++.h>
using namespace std;
const long long int inf = 1e9 + 7;
const long long int mod = 998244353;
long long int mini(long long int a, long long int b) {
  if (a >= b) return b;
  return a;
}
long long int maxi(long long int a, long long int b) {
  if (a >= b) return a;
  return b;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    long long int n = s.length();
    s = " " + s;
    long long int ans = 0;
    long long int prev = 0;
    for (long long int i = 1; i <= n; i++) {
      if (s[i] == '0') {
        prev++;
        continue;
      }
      long long int val = 1;
      ans++;
      for (long long int j = i + 1; j <= n; j++) {
        val *= 2;
        val += s[j] - '0';
        if (prev + j - i + 1 >= val)
          ans++;
        else
          break;
      }
      prev = 0;
    }
    cout << ans;
    cout << "\n";
  }
  return 0;
}
