#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:102400000,102400000")
long long mul(long long a, long long b) { return (a * b) % (1000000007); }
long long add(long long a, long long b) { return (a + b) % (1000000007); }
long long sub(long long a, long long b) {
  return ((a - b) % (1000000007) + (1000000007)) % (1000000007);
}
void upd(long long &a, long long b) {
  a = (a % (1000000007) + b % (1000000007)) % (1000000007);
}
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
char st[200005];
int pr[200005];
int a[200003], s[200003];
unordered_map<long long, int> h;
int main() {
  int T = 1;
  while (T--) {
    scanf("%s", st);
    int n = strlen(st);
    s[0] = 0;
    int p = 0;
    for (register int i = 1; i <= n; i++) {
      a[i] = st[i - 1] - '0';
      s[i] = s[i - 1] + a[i];
      pr[i] = p;
      if (a[i]) p = i;
    }
    long long ans = 0;
    int M = min(n, 350);
    for (register int k = 1; k <= M; k++) {
      h.clear();
      for (int i = 0; i < n + 1; i++) {
        long long c = i - k * s[i];
        if (h.find(c) != h.end())
          ans += h[c], h[c]++;
        else
          h[c] = 1;
      }
    }
    for (register int i = 1; i <= n; i++) {
      register int now = (a[i] ? i : pr[i]);
      register int ct = 1;
      while (now && ct * (M + 1) <= i) {
        p = pr[now];
        int tmp = (i - p) / ct - max((i - now) / ct, M);
        ans += max(tmp, 0);
        now = p;
        ct++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
