#include <bits/stdc++.h>
using namespace std;
const int maxn = 300500;
char s[maxn];
int ans[maxn];
int main() {
  scanf("%s", s + 1);
  int n = strlen(s + 1);
  for (int i = 1, l, r; i <= n; i++) {
    for (l = i - 1, r = i + 1; l >= 1 && r <= n; l--, r++) {
      if (s[l] == s[r] && s[l] == s[i]) {
        ans[r] = max(ans[r], l);
        break;
      }
    }
  }
  long long last = 0;
  int mx = 0;
  for (int i = 1; i <= n; i++) mx = max(mx, ans[i]), last += mx;
  printf("%lld", last);
  return 0;
}
