#include <bits/stdc++.h>
using namespace std;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  long long ans = 0;
  long long cnt0 = 0, cnt1 = 0;
  long long r = 0;
  for (long long l = 0; l < s.size(); l++) {
    while (r < s.size() && (cnt0 != cnt1 || l == 0)) {
      if (s[r] == '0')
        cnt0++;
      else
        cnt1++;
      r++;
    }
    if (cnt0 == cnt1) {
      ans += r - l;
      l = r;
      continue;
    }
    if (l == r) r++;
    if (s[l] == '0')
      cnt0--;
    else
      cnt1--;
  }
  cout << ans << endl;
  return 0;
}
