#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  int n = s.size();
  vector<int> a(n + 1);
  for (int i = 0; i < n; i++) {
    a[i + 1] = a[i] + (s[i] == '1');
  }
  vector<int> nxt(n + 1);
  nxt[n] = n;
  int cur = n;
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == '1') cur = i;
    nxt[i] = cur;
  }
  int B = 200;
  long long ans = 0;
  for (int k = 1; k < B; k++) {
    map<long long, int> m;
    for (int i = 0; i <= n; i++) {
      ans += m[(long long)a[i] * k - i]++;
    }
  }
  for (int i = 0; i < n; i++) {
    int j = nxt[i] + 1, d = 1;
    while (j <= n && i + d * B <= n) {
      int nj = nxt[j] + 1;
      int id = i % d;
      int ma1 = (nj - 1 - id) / d, ma2 = (max(j, i + B * d) - 1 - id) / d;
      ans += max(ma1 - ma2, 0);
      j = nj;
      d++;
    }
  }
  cout << ans << endl;
}
