#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
char str[N];
int n, s[N];
map<int, int> p;
map<int, int>::iterator it;
int T;
long long ans;
long long calc(int d, int x) {
  if (x <= d * T) return 0;
  return x / d - T;
}
int main() {
  scanf("%s", str + 1);
  n = strlen(str + 1);
  for (int i = 1, _b = n; i <= _b; i++) s[i] = s[i - 1] + str[i] - '0';
  T = sqrt((double)n / log2(n));
  for (int k = 1, _b = T; k <= _b; k++) {
    p.clear();
    for (int i = 0, _b = n; i <= _b; i++) p[i - k * s[i]]++;
    for (it = p.begin(); it != p.end(); it++) {
      long long x = (*it).second;
      ans += x * (x - 1) / 2;
    }
  }
  for (int d = 1, _b = n / T; d <= _b; d++) {
    int l = 0, r = 0;
    for (int i = 1, _b = n; i <= _b; i++) {
      while (s[i] - s[l] > d) l++;
      while (s[i] - s[r] >= d) r++;
      ans += calc(d, i - l) - calc(d, i - r);
    }
  }
  printf("%lld\n", ans);
}
