#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    int j = (int)s.size();
    int ans = 0;
    for (int i = (int)s.size() - 1; i >= 0; i--) {
      if (s[i] != '0') {
        j = i;
      }
      int val = 0;
      for (int x = j; x < j + 20 && x < (int)s.size(); x++) {
        val = val * 2 + s[x] - '0';
        if (val > (int)s.size()) break;
        if (val == x - i + 1) {
          ans++;
        }
      }
    }
    cout << ans << '\n';
  }
}
