#include <bits/stdc++.h>
using namespace std;
unsigned long long n, num_ones;
string s;
vector<int> onepos;
long long a[200100];
int n1s[200100];
unsigned long long hack[200100];
unsigned long long vec[200100];
unordered_map<long long, vector<int> > vals;
unsigned long long count_sols(int k, int l, int r) {
  return r / k - (l - 1) / k;
}
unsigned long long count_sols2(int kmin, vector<int> &v) {
  int j = 0;
  unsigned long long total = 0;
  int N = v.size();
  for (int i = 0; i < N && j < N; i++) {
    for (; j < N && v[j] < v[i] + kmin; j++)
      ;
    total += N - j;
  }
  return total;
}
unsigned long long count_sols22(int kmin, int l, int r) {
  int j = l;
  unsigned long long total = 0;
  for (int i = l; i < r && j < r; i++) {
    for (; j < r && vec[j] < vec[i] + kmin; j++)
      ;
    total += r - j;
  }
  return total;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> s;
  n = s.size();
  onepos.push_back(-1);
  for (int i = 0; i < n; i++) {
    if (s[i] == '1') {
      onepos.push_back(i);
    }
  }
  num_ones = onepos.size() - 1;
  onepos.push_back(n);
  n1s[0] = 0;
  for (int i = 0; i < n; i++) {
    n1s[i + 1] = n1s[i] + (s[i] == '1' ? 1 : 0);
  }
  unsigned long long total = 0, term;
  int k;
  for (k = 1; k * k <= n; k++) {
    term = 0;
    for (int i = 0; i < n; i++) {
      if (n1s[i] + k > num_ones) break;
      term +=
          count_sols(k, onepos[n1s[i] + k] - i + 1, onepos[n1s[i] + k + 1] - i);
    }
    total += term;
  }
  for (int d = 0; d * d <= n; d++) {
    a[0] = 0;
    hack[0] = (n << 32);
    for (int i = 1; i <= n; i++) {
      if (s[i - 1] == '1') {
        a[i] = a[i - 1] + d;
      } else {
        a[i] = a[i - 1] - 1;
      }
      hack[i] = ((a[i] + n) << 32) + i;
    }
    sort(hack, hack + n + 1);
    unsigned long long key, old_key;
    int j;
    term = 0;
    for (int i = 0; i <= n;) {
      old_key = hack[i] >> 32;
      j = i;
      while (j <= n && (hack[j] >> 32) == old_key) {
        vec[j] = hack[j] & 0xffffffff;
        j++;
      }
      term += count_sols22(k * (d + 1), i, j);
      i = j;
    }
    total += term;
  }
  cout << total << endl;
  return 0;
}
