#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
const int N = 200005;
const int M = 300;
const int OFF = N * M;
int _cnt[N + N * M];
int *cnt = _cnt + OFF;
int main() {
  char s[N];
  scanf("%s", s);
  int n = strlen(s);
  int psum[N];
  for (int i = 0; i < n; i++) {
    s[i] -= '0';
    psum[i] = s[i];
    if (i) psum[i] += psum[i - 1];
  }
  int sq = min(M, (int)sqrt(n));
  ll ans = 0;
  for (int j = 1; j < sq; j++) {
    cnt[-1] = 1;
    for (int i = 0; i < n; i++) {
      int val = i - j * psum[i];
      if (psum[i]) {
        ans += cnt[val];
      }
      cnt[val]++;
    }
    for (int i = 0; i < n; i++) {
      int val = i - j * psum[i];
      cnt[val]--;
    }
  }
  int nxt[N];
  nxt[n] = n;
  for (int i = n - 1; i >= 0; i--) {
    nxt[i] = nxt[i + 1];
    if (s[i] == 1) nxt[i] = i;
  }
  for (int i = 0; i < n; i++) {
    int r = nxt[i];
    int q = 1;
    while (r < n && q * sq <= n - i) {
      int p = nxt[r + 1];
      int rig = max(r, i + q * sq - 1);
      if (rig <= p) {
        ans += (p - i) / q - (rig - i) / q;
      }
      r = p;
      q++;
    }
  }
  printf("%lld\n", ans);
  return 0;
}
