#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable : 4996)
const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
char s[200001];
int nxt[200000];
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    scanf("%s", s);
    int len = strlen(s);
    for (int i = 0; i < len; i++) {
      if (s[i] == '1')
        nxt[i] = i;
      else
        nxt[i] = (i == 0 ? -1 : nxt[i - 1]);
    }
    int ans = 0;
    for (int r = 0; r < len; r++) {
      int sum = 0;
      for (int l = r; l >= 0 && r - l < 20; l--) {
        if (s[l] == '0') continue;
        sum += 1 << (r - l);
        if (sum <= r - (l == 0 ? -1 : nxt[l - 1])) ans++;
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
