#include <bits/stdc++.h>
using namespace std;
const int mx = 200005;
char s[mx];
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    scanf("%s", s);
    int n = strlen(s);
    int x = floor(log2(n)) + 1;
    long long int ans = 0;
    for (int i = 1; i <= x; ++i) {
      int px = 0;
      for (int j = 0; j < (n - i + 1); ++j) {
        if (s[j] == '1') {
          int u = j;
          int e = 0;
          for (int r = i - 1; r >= 0; --r) {
            if (s[u] == '1') {
              e += pow(2, r);
            }
            u++;
          }
          int len = floor(log2(e)) + 1;
          e -= len;
          if (px >= e) {
            ans++;
          }
          px = 0;
        } else {
          px++;
        }
      }
    }
    printf("%lld\n", ans);
  }
  return 0;
}
