#include <bits/stdc++.h>
using namespace std;
char s[300010];
int a[300010];
int main() {
  scanf("%s", s + 1);
  int len = strlen(s + 1);
  int cnt = 0;
  long long res = 0;
  for (int i = 3; i <= len; i++) {
    for (int j = i - 2; j >= cnt; j -= 2) {
      if (s[i] == s[j] && s[i] == s[(i + j) / 2]) {
        cnt = max(cnt, j);
        break;
      }
    }
    res += cnt;
  }
  printf("%lld\n", res);
}
