#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAX_N = 2e5 + 5;
string s;
void solve() {
  int n = s.length();
  int ans = 0;
  int res = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '1') {
      int x = 0;
      for (int j = i; j < n && j < i + 20; j++) {
        x = x * 2 + s[j] - '0';
        if (x >= j - i + 1 && x <= j - i + 1 + ans) res++;
      }
      ans = 0;
    } else
      ans++;
  }
  printf("%d\n", res);
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    cin >> s;
    solve();
  }
  return 0;
}
