#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e6 + 10;
const int mod = 1e9 + 7;
char s[maxn];
int num[maxn];
int two[30];
void init() {
  two[0] = 1;
  for (int i = 1; i <= 20; i++) two[i] = two[i - 1] * 2;
}
int main() {
  int T;
  cin >> T;
  init();
  while (T--) {
    scanf("%s", s + 1);
    int len = strlen(s + 1);
    for (int i = len; i >= 1; i--) {
      num[len - i + 1] = num[len - i] + (s[i] == '1');
    }
    int ans = 0;
    for (int i = 1; i <= len; i++) {
      int res = 0;
      int End = min(len, i + 19);
      for (int j = i; j <= End; j++) {
        res += two[j - i] * (num[j] - num[j - 1]);
        if (res == j - i + 1) ans++;
      }
      if (End < len) {
        if (res > End - i + 1) {
          int k = res - (End - i + 1);
          if (End + k > len) continue;
          if (num[End + k] - num[End] == 0) ans++;
        }
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
