#include <bits/stdc++.h>
using namespace std;
const int BLOCK = 250;
const int N = 200100;
const int NB = BLOCK * N;
long long ans = 0ll;
int sm[NB + N], pf[N], n, pr[N];
string s;
int calc(int len, int kol) { return len / kol; }
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> s;
  n = ((int)s.size());
  pf[0] = 0;
  for (int i = 1; i <= n; i++) pf[i] = pf[i - 1] + (s[i - 1] == '1' ? 1 : 0);
  for (int k = 1; k < BLOCK; k++) {
    for (int i = 0; i <= n; i++) sm[k * pf[i] - i + N] = 0;
    for (int i = 0; i <= n; i++) {
      int cv = k * pf[i] - i + N;
      ans += sm[cv];
      sm[cv]++;
    }
  }
  pr[0] = -1;
  for (int i = 1; i <= n; i++) {
    pr[i] = pr[i - 1];
    if (s[i - 1] == '1') pr[i] = i;
  }
  for (int r = 1; r <= n; r++) {
    int i = r;
    for (int it = 1; it <= 2 * BLOCK; it++) {
      int nw = pr[i];
      if (nw < 0) break;
      i = nw - 1;
      int l = max(0, pr[i]);
      int cans = calc(r - l, it) - calc(r - i - 1, it);
      int mn = (r - i) / it + bool((r - i) % it > 0);
      int mx = (r - l) / it;
      mx = min(mx, BLOCK - 1);
      cans -= max(0, mx - mn + 1);
      ans += cans;
    }
  }
  cout << ans;
  return 0;
}
