#include <bits/stdc++.h>
using namespace std;
const int MAX = 200005;
const int K = 150;
int pref[MAX], a[MAX], pos[MAX], cntof1 = 0;
int main() {
  string s;
  cin >> s;
  int n = (int)s.length();
  pos[cntof1++] = -1;
  for (int i = 1; i <= n; i++) {
    pref[i] = pref[i - 1] + (s[i - 1] - '0');
    if (pref[i] > pref[i - 1]) pos[cntof1++] = i - 1;
  }
  pos[cntof1] = n;
  long long ans = 0;
  for (int q = 1; q <= K; q++) {
    for (int i = 0; i <= n; i++) {
      a[i] = i - q * pref[i];
    }
    sort(a, a + n + 1);
    long long res = 1;
    for (int i = 1; i <= n; i++) {
      if (a[i] == a[i - 1])
        ++res;
      else {
        ans += (res * (res - 1)) / 2;
        res = 1;
      }
    }
    if (res != 1) ans += (res * (res - 1)) / 2;
  }
  int up = K;
  for (int winsz = 1; up <= n; winsz++, up += K) {
    for (int i = 1; i <= cntof1 - winsz; i++) {
      int right = pos[i + winsz] - pos[i + winsz - 1] - 1;
      for (int j = pos[i - 1] + 1; j <= pos[i]; j++) {
        int L = pos[i + winsz - 1] - j + 1;
        int r = (winsz - L) % winsz;
        while (r < 0) r += winsz;
        if (r > right) continue;
        int tmax = (right - r) / winsz;
        int tmin = (up - (r + L)) / winsz + 1;
        tmin = max(0, tmin);
        int t = tmax - tmin + 1;
        t = max(0, t);
        ans += t;
      }
    }
  }
  cout << ans;
  return 0;
}
