#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
string s;
int p[N], prv[N];
int main() {
  cin >> s;
  int last = 0;
  int n = s.size();
  s = "@" + s;
  for (int i = 1; i <= n; ++i) {
    p[i] = p[i - 1];
    prv[i] = last;
    if (s[i] == '1') {
      last = i;
      ++p[i];
    }
  }
  prv[n + 1] = last;
  int sq = 100;
  long long ans = 0;
  unordered_map<long long, long long> f;
  for (int k = 1; k <= sq; ++k) {
    f.clear();
    f[0] = 1;
    for (int i = 1; i <= n; ++i) {
      ans += f[i - k * p[i]];
      ++f[i - k * p[i]];
    }
  }
  for (int i = 1; i <= n; ++i) {
    int cnt = 1, x = prv[i + 1];
    auto f = [&](int x) { return x / cnt; };
    while (x) {
      int nxt = prv[x], y = prv[x];
      int t = i - (sq + 1) * cnt;
      if (t < 0) break;
      x = min(x, t + 1);
      y = min(y, t + 1);
      if (x >= nxt) {
        int st = i - (x - 1), en = i - y;
        ans += f(en) - f(st - 1);
      }
      x = nxt;
      ++cnt;
    }
  }
  cout << ans << '\n';
}
