#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int maxn = 2e5;
const int block = 200;
char s[maxn + 5];
int n, sum[maxn + 5], pre[maxn + 5], mp[maxn * block + 5];
long long res;
int cal(int x, int k) {
  if (x <= 0) return 0;
  return x / k;
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; ++i) {
    sum[i] = (s[i] == '1');
    sum[i] += sum[i - 1];
  }
  int pos = 0;
  for (int i = 1; i <= n; ++i) {
    if (s[i] == '1') pos = i;
    pre[i] = pos;
  }
  for (int k = 1; k <= block; ++k) {
    mp[n] = 1;
    for (int i = 1; i <= n; ++i) {
      int val = k * sum[i] - i + n;
      res += mp[val];
      mp[val] += 1;
    }
    for (int i = 1; i <= n; ++i) mp[k * sum[i] - i + n] -= 1;
  }
  for (int len = 1; len <= n / block + 1; ++len) {
    for (int i = 1, r = 1; i <= n; ++i) {
      while (r < n && sum[r + 1] - sum[i - 1] <= len) ++r;
      if (sum[r] - sum[i - 1] == len)
        res += max(0, cal(r - i + 1, len) -
                          cal(max(pre[r] - i, (block + 1) * len - 1), len));
    }
  }
  printf("%lld\n", res);
  return 0;
}
