#include <bits/stdc++.h>
using namespace std;
const int N = (int)2e5 + 5;
const int K = 30;
int p[N];
char s[N];
int get(int l, int r, int s) {
  l = max(l, s * K);
  if (l > r) return 0;
  return r / s - l / s;
}
int main() {
  scanf("%s", s);
  int n = strlen(s);
  for (int i = 0; i < n; ++i) p[i + 1] = p[i] + (int)(s[i] == '1');
  long long ans = 0;
  map<int, int> cnt;
  for (int k = 1; k <= K; ++k) {
    cnt.clear();
    for (int i = 0; i <= n; ++i) ++cnt[i - k * p[i]];
    for (auto pr : cnt) ans += pr.second * (long long)(pr.second - 1) / 2;
  }
  vector<int> one;
  for (int i = 0; i < n; ++i)
    if (s[i] == '1') one.push_back(i);
  one.push_back(n);
  reverse((one).begin(), (one).end());
  for (int i = 0; i < n; ++i) {
    int sz = (int)(one).size();
    for (int j = 0; j < min(n / K + 1, sz - 1); ++j)
      ans += get(one[sz - j - 1] - i, one[sz - (j + 1) - 1] - i, j + 1);
    if (s[i] == '1') one.pop_back();
  }
  printf("%lld\n", ans);
}
