#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
using namespace std;
const long double eps = 1e-7;
const int inf = 1000000010;
const long long INF = 10000000000000010LL;
const int mod = 1000000007;
const int MAXN = 200010, SQ = 120;
int n, m, k, u, v, x, y, t, a, b;
long long ans;
int A[MAXN];
int ps[MAXN];
int prv[MAXN], nxt[MAXN];
unordered_map<int, int> cnt;
deque<int> dq;
string S;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> S;
  n = S.size();
  for (int i = 1; i <= n; i++) {
    A[i] = (S[i - 1] == '1');
    prv[i] = prv[i - 1];
    if (A[i - 1]) prv[i] = i - 1;
  }
  for (int i = n; i; i--) {
    nxt[i] = nxt[i + 1];
    if (A[i + 1]) nxt[i] = i + 1;
  }
  for (int k = 1; k <= SQ; k++) {
    cnt.clear();
    cnt[0] = 1;
    for (int i = 1; i <= n; i++) {
      if (A[i])
        ps[i] = k - 1;
      else
        ps[i] = -1;
      ps[i] += ps[i - 1];
      ans += cnt[ps[i]];
      cnt[ps[i]]++;
    }
  }
  for (int kk = 1; kk * SQ <= n; kk++) {
    dq.clear();
    for (int i = 1; i <= n; i++) {
      if (A[i]) dq.push_front(i);
      if (dq.size() > kk) dq.pop_back();
      if (dq.size() == kk) {
        int l = i - (dq.back() - 1), r = i - (prv[dq.back()]);
        l = (l + kk - 1) / kk;
        r = r / kk;
        l = max(l, SQ + 1);
        r++;
        if (r - l <= 0) continue;
        ans += r - l;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}
