#include <bits/stdc++.h>
using namespace std;
char s[200010];
int T, N;
int Solve() {
  N = strlen(s + 1);
  int Ans = 0, Len = 1;
  while ((1 << (Len)) <= N) ++Len;
  for (register int i = 1; i <= N; ++i) {
    if (s[i] == '0') continue;
    int p = i, num = 0;
    while (p > 1 && s[p - 1] == '0') --p;
    for (register int j = i; j <= min(i + Len - 1, N); ++j) {
      num = (num << 1) + s[j] - '0';
      if (num > N) break;
      int L = j - i + 1, R = j - p + 1;
      if (L <= num && num <= R) ++Ans;
    }
  }
  return Ans;
}
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%s", s + 1);
    printf("%d\n", Solve());
  }
  return 0;
}
