#include <bits/stdc++.h>
using namespace std;
int main() {
  long int t;
  cin >> t;
  while (t--) {
    long long int i, j, k, x, ans = 0;
    string s;
    cin >> s;
    vector<long long> v;
    for (i = 0; i < s.size(); i++) {
      if (s[i] - '0') v.push_back(i);
    }
    for (i = 0; i < s.size(); i++) {
      if (s[i] - '0') {
        x = 1;
        j = i;
        while (j < s.size()) {
          if (x == j - i + 1) ans++;
          if (j - i + 1 > 2) break;
          j++;
          x = x << 1;
          if (s[j] == '1') x++;
        }
      } else {
        j = lower_bound(v.begin(), v.end(), i) - v.begin();
        if (j == v.size()) continue;
        j = v[j];
        x = 1;
        while (j < s.size()) {
          if (x == j - i + 1) {
            ans++;
            break;
          }
          j++;
          x = x << 1;
          if (x > 200000) break;
          if (s[j] == '1') x++;
        }
      }
    }
    cout << ans << endl;
  }
}
