#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops,-ffloat-store")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
using namespace std;
const int sq = 300;
const int maxn = 2e5 + 5;
const int tt = 6e7;
const int maxd = 7e7;
long long ans;
int nxt[maxn], f[maxn], n, dem[maxd];
string s;
void readf() {
  cin >> s;
  n = s.size();
  s = " " + s;
  for (int i = 1; i <= n; ++i) f[i] = f[i - 1] + (s[i] == '1');
}
void solve() {
  nxt[n + 1] = n + 1;
  for (int i = n; i > 0; --i)
    if (s[i] == '1')
      nxt[i] = i;
    else
      nxt[i] = nxt[i + 1];
  ans = 0;
  for (int i = 1; i <= n; ++i) {
    int cnt = 0;
    int j = i;
    while (cnt <= 700) {
      j = nxt[j];
      if (j > n) break;
      cnt++;
      int R = nxt[j + 1] - 1;
      ans += max(0, (R - i + 1) / cnt - max(sq, (j - i) / cnt));
      j++;
    }
  }
  for (int k = 1; k <= sq; ++k) {
    for (int i = 0; i <= n; ++i) dem[i - k * f[i] + tt] = 0;
    for (int i = 0; i <= n; ++i) {
      ans += dem[i - k * f[i] + tt];
      dem[i - k * f[i] + tt]++;
    }
  }
  cout << ans << '\n';
}
int main() {
  srand(time(NULL));
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  readf();
  solve();
}
