#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native,avx2")
void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << "\n";
  err(++it, args...);
}
const double PI = acos(-1);
const double eps = (1e-9);
const long long int INF = 1e18;
const int M = (1e9) + 7;
const int N = (2e5) + 5;
const int T = 100;
int sum[N];
int agla[N];
long long int ans = 0;
void add(long long int m) {
  ans += ((m * (m - 1)) / 2);
  return;
}
int main() {
  int n, i, j, a, l, r, p, c, d, k;
  string str;
  cin >> str;
  str = "0" + str;
  n = str.size();
  for (i = 0; i < n; ++i) sum[i] = str[i] - '0';
  for (i = 1; i < n; ++i) sum[i] += sum[i - 1];
  vector<int> ar(n);
  for (k = 1; k < T + 1; ++k) {
    for (i = 0; i < n; ++i) ar[i] = i - k * sum[i];
    sort(ar.begin(), ar.end());
    i = 0;
    while (i < n) {
      j = i;
      while (j < n && ar[j] == ar[i]) ++j;
      add(j - i);
      i = j;
    }
  }
  int P;
  a = n;
  for (i = n - 1; i >= 0; --i) {
    agla[i] = a;
    if (str[i] == '1') a = i;
  }
  for (l = 0; l < n; ++l) {
    r = agla[l], p = 1, P = (n - l), P /= T;
    while (p <= P && r < n) {
      a = agla[r];
      c = (r - l - 1), c /= p, ++c;
      d = (a - l - 1), d /= p, ++d;
      c = max(c, T + 1);
      if (d > c) ans += (d - c);
      r = a, ++p;
    }
  }
  cout << ans << "\n";
}
