#include <bits/stdc++.h>
using namespace std;
int main() {
  int T;
  cin >> T;
  while (T--) {
    string str;
    cin >> str;
    int N = str.size();
    long ans = 0;
    int bits = 0;
    int x = N;
    while (x) {
      bits++;
      x /= 2;
    }
    for (int len = 1; len <= bits; len++) {
      int zerocount = 0;
      for (int i = 0; i + len - 1 < N; i++) {
        if (str[i] == '1') {
          int mult = 1, sum = 0;
          for (int j = i + len - 1; j >= i; j--, mult *= 2)
            if (str[j] == '1') sum += mult;
          if (sum <= len + zerocount) ans++;
          zerocount = 0;
        } else
          zerocount++;
      }
    }
    cout << ans << endl;
  }
}
