#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
char s[N];
int main() {
  scanf("%s", s + 1);
  int n = strlen(s + 1);
  int p = 0;
  long long ans = 0;
  for (int i = 3; i <= n; ++i) {
    for (int j = p + 1; j <= i - 2; ++j)
      if ((i - j) % 2 == 0 && s[i] == s[j] && s[i] == s[(i + j) / 2]) p = j;
    ans += p;
  }
  printf("%lld\n", ans);
}
