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