#include <bits/stdc++.h>
char s[310000];
int n;
long long ans;
inline bool che(int l, int r) {
  for (int i = l; i <= r; i++)
    for (int j = i + 2, k = i + 1; j <= r; j += 2, k++)
      if (s[i] == s[j] && s[i] == s[k]) return 1;
  return 0;
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int l = 1; l <= n; l++)
    for (int r = l + 2; r <= n; r++)
      if (che(l, r)) {
        ans += n - r + 1;
        break;
      }
  printf("%I64d\n", ans);
  return 0;
}
