#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int N = 2e5 + 5;
int n, b, s1[N], s0[N], cnt[N + 300 * N + 5];
char s[N];
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; ++i) {
    int x = s[i] == '1';
    s1[i] = s1[i - 1] + x;
    s0[i] = s0[i - 1] + !x;
  }
  b = sqrt(n + 0.5);
  b = min(300, b);
  ll ans = 0;
  for (int k = 0; k <= b; ++k) {
    vector<int> a;
    ++cnt[n];
    a.push_back(n);
    for (int i = 1; i <= n; ++i) {
      int cur = s1[i] * k - s0[i] + n;
      a.push_back(cur);
      ans += cnt[cur]++;
    }
    for (int x : a) cnt[x] = 0;
  }
  vector<int> l1(N), r1(N);
  r1[0] = 0;
  for (int i = 1; i <= n; ++i) {
    r1[s1[i]] = i;
    if (!l1[s1[i]]) l1[s1[i]] = i;
  }
  l1[0] = 0;
  for (int i = 1; i <= n; ++i) {
    for (int d = 1; d <= min(n / b, s1[i]); ++d) {
      int s1j = s1[i] - d;
      int l = l1[s1j], r = r1[s1j];
      int lb = s0[i] - s0[r], ub = s0[i] - s0[l];
      int ll = max((lb + d - 1) / d, b + 1);
      int rr = ub / d;
      if (rr >= ll) ans += rr - ll + 1;
    }
  }
  cout << ans << endl;
}
