#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
int main() {
  int t;
  char s[maxn];
  cin >> t;
  while (t--) {
    cin >> s;
    int bf0 = 0;
    int num = 0;
    int ans = 0;
    int n = strlen(s);
    for (int i = 0; i < n; i++) {
      num = 0;
      if (s[i] - '0' == 0)
        bf0++;
      else {
        num = num * 2 + 1;
        ans++;
        for (int j = i + 1; j < n; j++) {
          num = num * 2 + s[j] - '0';
          if (num <= j - i + 1 + bf0 && num >= j - i + 1) {
            ans++;
          } else if (num > j - i + 1 + bf0) {
            break;
          }
        }
        bf0 = 0;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
