#include <bits/stdc++.h>
using namespace std;
char s[200004];
set<int> tr[200004];
int f[200004];
int n;
long long ans;
void work(int ed, int len) {
  long long now = 0;
  for (int i = ed - len + 1; i <= ed; i++) {
    now <<= 1;
    if (s[i] == '1') now |= 1;
  }
  if (now == 0) return;
  if (s[ed - len + 1] == '1') {
    if (now == len) {
      if (!tr[ed - len + 1].count(now)) {
        tr[ed - len + 1].insert(now);
        ans++;
      }
    }
  } else {
    long long pre = f[ed - len + 1] + 1;
    long long nt = ed - now + 1;
    if (nt >= pre) {
      if (!tr[nt].count(now)) {
        tr[nt].insert(now);
        ans++;
      }
    }
  }
}
int w33ha() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 0; i <= n + 1; i++) {
    f[i] = 0;
    tr[i].clear();
  }
  for (int i = 1; i <= n; i++) {
    if (s[i] == '1')
      f[i] = i;
    else
      f[i] = f[i - 1];
  }
  ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int l = 1; l <= 32 && i + l - 1 <= n; l++) {
      work(i + l - 1, l);
    }
  }
  printf("%lld\n", ans);
  return 0;
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) w33ha();
  return 0;
}
