#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  char ch = getchar();
  long long s = 0, w = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    s = s * 10 + ch - '0';
    ch = getchar();
  }
  return s * w;
}
int z[300010][2];
deque<int> Q[2];
char s[300010];
int v[300010], n;
int r[300010];
int vis[2];
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (register int i = 1; i <= n; i++) v[i] = s[i] - '0';
  for (register int i = 1; i <= n; i++) r[i] = n + 1;
  for (register int i = n; i >= 1; i--) {
    if (!vis[v[i]]) {
      vis[v[i]] = 1;
      z[i][v[i]] = 1;
    } else {
      int tmp = Q[v[i]].size();
      for (register int j = 0; j < tmp; j++) {
        int x = Q[v[i]][j];
        if (z[2 * x - i][v[i]]) {
          r[i] = 2 * x - i;
          while (!Q[v[i]].empty() && Q[v[i]].back() >= x) {
            z[Q[v[i]].back()][v[i]] = 1;
            Q[v[i]].pop_back();
          }
          break;
        }
      }
      Q[v[i]].push_front(i);
      z[i][v[i]] = 1;
    }
  }
  for (register int i = n - 1; i >= 1; i--) r[i] = min(r[i], r[i + 1]);
  long long ans = 0;
  for (register int i = 1; i <= n; i++) ans += 1LL * (n - r[i] + 1);
  printf("%I64d\n", ans);
  return 0;
}
