#include <bits/stdc++.h>
#pragma GCC optimize("O3")
const double PI = acos(-1);
template <class A, class B>
std::ostream& operator<<(std::ostream& st, const std::pair<A, B> p) {
  st << "(" << p.first << ", " << p.second << ")";
  return st;
}
using namespace std;
int n;
char txt[1 << 20];
int S[1 << 20];
int f(int n, int r, int m) {
  if (r == 0) return n / m;
  return n / m + (r <= n % m);
}
int nxt[1 << 20];
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
int main() {
  scanf("%s", txt + 1);
  n = strlen(txt + 1);
  for (int i = 1; i <= n; i++) S[i] = S[i - 1] + txt[i] - '0';
  nxt[n + 1] = -1;
  for (int i = n; i >= 1; i--)
    nxt[i] = (txt[i + 1] == '1') ? i + 1 : nxt[i + 1];
  int B = sqrt(n);
  int big = (B + 1) * n;
  std::vector<int> freq(big + 1, 0);
  long long ans = 0;
  for (int k = 1; k <= B; k++) {
    for (int i = 0; i <= n; i++) {
      long long f = k * (long long)S[i] - i + n;
      ans += freq[f];
      freq[f]++;
    }
    for (int i = 0; i <= n; i++) {
      long long f = k * (long long)S[i] - i + n;
      freq[f]--;
    }
  }
  for (int k = 1; k <= B; k++) {
    int ctr = 0, s = 0;
    for (int l = 1; l <= n; l++) {
      while (s < n && ctr < k) {
        ++s;
        ctr += txt[s] == '1';
      }
      if (ctr != k) break;
      int e = nxt[s];
      if (e == -1)
        e = n;
      else
        e--;
      int r = (l - 1) % k;
      if (s - l + 1 > k * B) {
        ans += f(e, r, k) - f(s - 1, r, k);
      } else if (e - l + 1 > k * B) {
        ans += f(e, r, k) - f(l + k * B - 1, r, k);
      }
      ctr -= txt[l] == '1';
    }
  }
  cout << ans << endl;
  return 0;
}
