#include <bits/stdc++.h>
using namespace std;
const int N = 200006;
const int K = 314;
int ss[N];
int pre[N];
long long L[N];
long long R[N];
long long sz[N];
long long val[N];
long long gao(long long x) {
  if (x <= 0) return 0;
  return x * (x + 1) / 2;
}
long long gogo(long long sz, long long len) {
  long long tmp = sz - len * K;
  if (tmp < 0) return 0;
  long long num = tmp / len + 1;
  long long mod = (tmp) % len;
  cout << "sz = " << sz << " , len = " << len << " , num = " << num
       << " , mid = " << mod << " , tmp = " << tmp << endl;
  return num + mod * num + gao(tmp / len);
}
int main() {
  string s;
  cin >> s;
  int n = (int)s.size();
  for (int i = 0; i < n; ++i) {
    ss[i + 1] = s[i] - '0';
  }
  vector<int> go;
  for (int i = 1; i <= n; ++i) {
    pre[i] = pre[i - 1] + ss[i];
    if (ss[i] == 1) {
      go.push_back(i);
      sz[i] = 1;
    }
  }
  ss[0] = ss[n + 1] = 1;
  for (int i = 1; i <= n; ++i) {
    if (ss[i - 1] == 1)
      L[i] = i;
    else
      L[i] = L[i - 1];
  }
  R[n + 1] = n + 1;
  for (int i = n; i >= 1; --i) {
    if (ss[i + 1] == 1)
      R[i] = i;
    else
      R[i] = R[i + 1];
  }
  for (int i = 1; i <= n; ++i) {
    R[i] = R[i] - i;
    L[i] = i - L[i];
  }
  long long ans = 0;
  for (int k = 1; k < K; ++k) {
    vector<long long> v;
    for (int i = 0; i <= n; ++i) {
      long long val = k * pre[i] - i;
      v.push_back(val);
    }
    sort(v.begin(), v.end());
    v.push_back(v.back() + 1);
    long long last = (1ll << 60);
    long long pre = 0;
    for (long long i : v) {
      if (i == last) {
        ++pre;
      } else {
        ans += (pre) * (pre - 1) / 2;
        pre = 1;
        last = i;
      }
    }
  }
  for (int i = 1; i <= n / K; ++i) {
    for (int j : go) {
      for (int l = 0; l <= L[j]; ++l) {
        int now_len = l + sz[j];
        long long need = max(i * K - now_len, ((-now_len) % i + i) % i);
        if (R[j] < need) continue;
        ans += (R[j] - need) / i + 1;
      }
    }
    if (go.size() <= 1) break;
    for (int jj = (int)go.size() - 2; jj >= 0; --jj) {
      int j = go[jj];
      sz[j] += go[jj + i] - go[jj + i - 1];
    }
    for (int jj = 0; jj <= (int)go.size() - 2; ++jj) {
      int j = go[jj];
      R[j] = R[go[jj + 1]];
    }
    go.pop_back();
  }
  cout << ans << endl;
}
