#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005, SQRT = 450;
int pref[MAXN], byk[2 * MAXN];
vector<int> v;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  int n;
  long long ans = 0;
  cin >> s;
  n = s.length();
  v.push_back(0);
  for (int i = 0; i < n; i++) {
    pref[i + 1] = pref[i] + (s[i] == '1');
    if (s[i] == '1') v.push_back(i + 1);
  }
  v.push_back(n + 1);
  for (int k = 1; k <= SQRT; k++) {
    for (int i = 0; i < k; i++) {
      for (int j = i; j <= n; j += k) {
        ans += byk[pref[j] - j / k + n];
        byk[pref[j] - j / k + n]++;
      }
      for (int j = i; j <= n; j += k) byk[pref[j] - j / k + n]--;
    }
  }
  for (int i = 0; i < v.size(); i++) {
    for (int j = i + 2; j < min((int)v.size(), i + SQRT); j++) {
      int a = v[i + 1] - v[i] - 1, b = v[j - 1] - v[i + 1] + 1,
          c = v[j] - v[j - 1] - 1, e = j - i - 1;
      int dmin = max(SQRT, (b - 1) / e) + 1, dmax = (a + b + c) / e;
      if (dmin > dmax) continue;
      for (int k = dmin; k <= dmax; k++)
        ans += (min(k * e, b + c) - max(b, k * e - a) + 1);
    }
  }
  cout << ans << '\n';
  return 0;
}
