#include <bits/stdc++.h>
using namespace std;
char dat[1048576];
long long countSub(long long a, long long b, long long left, long long right,
                   long long d) {
  long long low = b * d - a;
  if (low < 0) {
    if (a % b != 0) {
      low = b - a % b;
    } else {
      low = 0;
    }
  }
  long long high = left + right;
  if (low > high) return 0;
  high -= (high - low) % b;
  if (left > right) swap(left, right);
  long long ans = 0;
  long long firstcnt = 0, fb = low;
  long long secondcnt = 0, sb = 0;
  long long thirdcnt = 0, tb = 0;
  if (fb <= left) {
    if (high <= left) {
      firstcnt = (high - fb) / b + 1;
    } else {
      firstcnt = (left - fb) / b + 1;
    }
  }
  sb = fb + firstcnt * b;
  if (high >= sb && sb <= right) {
    if (high <= right) {
      secondcnt = (high - sb) / b + 1;
    } else if (high > right) {
      secondcnt = (right - sb) / b + 1;
    }
  }
  tb = sb + secondcnt * b;
  if (high >= tb) {
    thirdcnt = (high - tb) / b + 1;
  }
  if (firstcnt > 0)
    ans += ((fb + 1) + (fb + (firstcnt - 1) * b + 1)) * firstcnt / 2;
  if (secondcnt > 0) ans += ((left + 1) + (left + 1)) * secondcnt / 2;
  if (thirdcnt > 0)
    ans += ((left + right + 1 - (tb)) +
            (left + right + 1 - (tb + (thirdcnt - 1) * b))) *
           thirdcnt / 2;
  return ans;
}
int main() {
  scanf("%s", dat);
  int n = (int)strlen(dat);
  int n0 = 0, n1 = 0;
  for (int i = 0; i < n; i++) {
    if (dat[i] == '0') {
      n0++;
    } else {
      n1++;
    }
  }
  long long ans = 0;
  int maxratio = 0;
  for (int ratio = 0; ratio <= 100 || 12 * ratio * ratio <= n; ratio++) {
    maxratio = ratio;
    long long depth = 0;
    unordered_map<long long, int> cnt;
    cnt.reserve(n + 10);
    cnt[0] = 1;
    for (int i = 0; i < n; i++) {
      if (dat[i] == '0') {
        depth--;
      } else {
        depth += ratio;
      }
      ans += (cnt[depth]++);
    }
  }
  vector<int> ones;
  for (int i = 0; i < n; i++)
    if (dat[i] == '1') ones.emplace_back(i);
  for (int i = 0; i < ones.size(); i++) {
    for (int j = i; j < ones.size(); j++) {
      int onecnt = j - i + 1;
      if (onecnt * maxratio > n0) break;
      int left = (i == 0 ? ones[0] : (ones[i] - ones[i - 1] - 1));
      int right = (j + 1 == ones.size() ? (n - 1 - ones[j])
                                        : (ones[j + 1] - ones[j] - 1));
      int zerocnt = ones[j] - ones[i] + 1 - onecnt;
      ans += countSub(zerocnt, onecnt, left, right, maxratio + 1);
    }
  }
  printf("%lld\n", ans);
  return 0;
}
