#include <bits/stdc++.h>
using namespace std;
template <class T>
bool checkmin(T &a, T b) {
  return (b < a ? a = b, 1 : 0);
}
template <class T>
bool checkmax(T &a, T b) {
  return (b > a ? a = b, 1 : 0);
}
template <class T>
T _min(T a, T b) {
  return (a < b ? a : b);
}
template <class T>
T _max(T a, T b) {
  return (a > b ? a : b);
}
const int N = 200015;
char s[N];
int n, a[N], l[N], r[N];
double A;
struct hash_table {
  int MOD = 200009, e = 0;
  int first[N], nxt[N], num[N], cnt[N];
  void clear() {
    e = 0;
    memset(first, -1, sizeof first);
    memset(cnt, 0, sizeof cnt);
  }
  void insert(int x) {
    int tmp = x;
    x %= MOD;
    if (x < 0) x += MOD;
    for (int i = first[x]; i != -1; i = nxt[i]) {
      if (num[i] == tmp) {
        ++cnt[i];
        return;
      }
    }
    ++e;
    nxt[e] = first[x];
    first[x] = e;
    cnt[e] = 1;
    num[e] = tmp;
  }
  int find(int x) {
    int tmp = x;
    x %= MOD;
    if (x < 0) x += MOD;
    for (int i = first[x]; i != -1; i = nxt[i]) {
      if (num[i] == tmp) {
        return cnt[i];
      }
    }
    return 0;
  }
} mp;
void init() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; ++i) {
    a[i] = a[i - 1] + (s[i] == '1');
  }
  for (int i = 0; i <= n; ++i) {
    r[a[i]] = i;
  }
  for (int i = n; i >= 0; --i) {
    l[a[i]] = i;
  }
}
void solve() {
  long long ans = 0;
  int m = sqrt(n) + 1, p = n / m;
  for (int k = 1; k < m; ++k) {
    mp.clear();
    mp.insert(0);
    int tmp = 0;
    for (int i = 1; i <= n; ++i) {
      tmp = k * a[i] - i;
      ans += mp.find(tmp);
      mp.insert(tmp);
    }
  }
  for (int i = 1; i <= n; ++i) {
    for (int d = 1, lim = _min(p, a[i]); d <= lim; ++d) {
      int L = l[a[i] - d], R = r[a[i] - d];
      int down = _max(m, (i - R + d - 1) / d);
      int up = (i - L) / d;
      if (up >= down) ans += (up - down + 1);
    }
  }
  printf("%lld\n", ans);
}
int main() {
  init();
  solve();
  return 0;
}
