#include <bits/stdc++.h>
using namespace std;
int t, n, c, k, ans;
string s;
int main() {
  cin >> t;
  while (t--) {
    cin >> s;
    n = s.size();
    ans = c = k = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] == '0')
        c++;
      else {
        k = 0;
        for (int j = i; j < n && j < i + 20; j++) {
          c++;
          k *= 2;
          if (s[j] == '1') k += 1;
          if (c >= k) ans++;
        }
        c = 0;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
