#include <bits/stdc++.h>
using namespace std;
long long ans, kq, n;
string s;
int dem;
int main() {
  cin >> n;
  while (n > 0) {
    n--;
    cin >> s;
    ans = 0;
    dem = 0;
    for (int j = 0; j <= s.size() - 1; j++) {
      if (s[j] == '0')
        dem++;
      else {
        kq = 0;
        for (int i = j; i <= (s.size() - 1); i++) {
          dem++;
          if (s[i] == '1')
            kq = kq * 2 + 1;
          else
            kq = kq * 2;
          if (dem >= kq) ans += 1;
          if (kq > 2 * int(1e5) + 1) break;
        }
        dem = 0;
      }
    }
    cout << ans << endl;
  }
}
