#include <bits/stdc++.h>
using namespace std;
int N, ONES_CUTOFF, RATIO_CUTOFF;
string S;
vector<int> ones_count;
vector<int> freq;
long long solve_ratio_with_min_ones(int ratio) {
  int min_length = ratio * (ONES_CUTOFF + 1);
  vector<int> values(N + 1);
  long long total = 0;
  for (int end = 0; end <= N; end++) {
    if (end >= min_length) freq[values[end - min_length]]++;
    values[end] = ratio * ones_count[end] - end + N;
    total += freq[values[end]];
  }
  for (int start = 0; start <= N - min_length; start++) freq[values[start]] = 0;
  return total;
}
long long solve_small_ratio_with_min_ones() {
  freq.assign((RATIO_CUTOFF + 1) * N + 1, 0);
  long long total = 0;
  for (int ratio = 1; ratio <= RATIO_CUTOFF; ratio++)
    total += solve_ratio_with_min_ones(ratio);
  return total;
}
int count_sum(int a, int b, int sum) {
  return max(min(a, sum + 1) + min(b, sum + 1) - (sum + 1), 0);
}
long long count_sum_multiples(int a, int b, int extra, int k) {
  long long initial = (long long)(a / k) * b + (long long)(a % k) * (b / k);
  a %= k;
  b %= k;
  int goal = extra % k == 0 ? 0 : k - extra % k;
  return initial + count_sum(a, b, goal) + count_sum(a, b, goal + k);
}
vector<int> positions;
long long solve_ones(int ones) {
  long long total = 0;
  int P = positions.size();
  for (int i = 1; i + ones <= P - 1; i++) {
    int left = positions[i] - positions[i - 1];
    int right = positions[i + ones] - positions[i + ones - 1];
    total += count_sum_multiples(
        left, right, positions[i + ones - 1] - positions[i] + 1, ones);
  }
  return total;
}
long long solve_small_ones() {
  positions = {-1};
  for (int i = 0; i < N; i++)
    if (S[i] == '1') positions.push_back(i);
  positions.push_back(N);
  long long total = 0;
  for (int ones = 1; ones <= ONES_CUTOFF; ones++) total += solve_ones(ones);
  return total;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> S;
  N = S.size();
  ones_count.assign(N + 1, 0);
  for (int i = 0; i < N; i++) ones_count[i + 1] = ones_count[i] + (S[i] - '0');
  ONES_CUTOFF = 1.25 * sqrt(N) + 1;
  RATIO_CUTOFF = N / ONES_CUTOFF;
  long long ratio_ans = solve_small_ratio_with_min_ones();
  long long ones_ans = solve_small_ones();
  cout << ratio_ans + ones_ans << '\n';
}
