#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1000000000")
using namespace std;
const int maxn = (int)3e5 + 10;
char s[maxn];
bool good(int l, int r) {
  int d = r - l + 1;
  for (int k = 1; k <= d; k++) {
    if (r - 2 * k < l) {
      break;
    }
    if (s[r] == s[r - k] && s[r] == s[r - 2 * k]) {
      return false;
    }
  }
  return true;
}
int main() {
  scanf("%s", s);
  int n = strlen(s);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int r = i;
    while (r < n && good(i, r)) {
      r++;
    }
    ans += n - r;
  }
  cout << ans << endl;
}
