#include <bits/stdc++.h>
using namespace std;
template <typename T>
void print(const vector<T>& s) {
  for (auto x : s) cout << x << ' ';
  cout << endl;
}
template <class T>
void print(const T* s, int n) {
  for (int i = 0; i < n; i++) cout << s[i] << ' ';
  cout << endl;
}
template <class T>
void print(vector<vector<T>> s) {
  for (int i = 0; i < s.size(); i++) print(s[i]);
}
const int K = 500;
void solve() {
  string ss;
  cin >> ss;
  int n = ss.size();
  vector<int> pref(n + 1);
  long long answer = 0;
  for (int d = 1; d < K; d++) {
    pref[0] = 0;
    for (int i = 0; i < n; i++) {
      pref[i + 1] = pref[i];
      if (ss[i] == '1')
        pref[i + 1] -= d - 1;
      else
        pref[i + 1]++;
    }
    sort(pref.begin(), pref.end());
    int now = 0;
    long long asasddlsa = 1e18;
    for (int x : pref) {
      if (x == asasddlsa)
        now++;
      else
        now = 1;
      asasddlsa = x;
      answer += now - 1;
    }
  }
  vector<int> ones;
  for (int i = 0; i < n; i++) {
    if (ss[i] == '1') ones.push_back(i);
  }
  for (int i = 0; i < n; i++) {
    int pos = lower_bound(ones.begin(), ones.end(), i) - ones.begin();
    for (int j = pos; j < min(pos + K, (int)ones.size()); j++) {
      int len = ones[j] - i;
      int can = (j + 1 < ones.size() ? ones[j + 1] : n) - ones[j];
      int t = j - pos + 1;
      answer += max((len + can) / t - max(len / t, K - 1), 0);
    }
  }
  cout << answer << endl;
}
int main() {
  srand(time(0));
  ios_base::sync_with_stdio(0);
  int t = 1;
  while (t--) solve();
  return 0;
}
