#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int _ = 0; _ < t; ++_) {
    string str;
    cin >> str;
    int pw = 1;
    int c = 1;
    while (pw <= str.size()) {
      pw *= 2;
      ++c;
    }
    vector<int> din(str.length());
    int cnt = 0;
    for (int i = 0; i < str.length(); ++i) {
      din[i] = cnt;
      if (str[i] == '0') {
        cnt++;
      } else {
        cnt = 0;
      }
    }
    int ans = 0;
    for (int i = 1; i <= c; ++i) {
      for (int j = 0; j + i <= str.length(); ++j) {
        int r = stoi(str.substr(j, i), nullptr, 2);
        if (str[j] == '1' && din[j] >= r - i) {
          ++ans;
        }
      }
    }
    cout << ans << endl;
  }
}
