#include <bits/stdc++.h>
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
int Read() {
  char c;
  c = getchar();
  int tsqua = 0;
  while (c != ' ' && c != '\n') {
    tsqua = (((tsqua << 1) << 1) << 1) + (tsqua << 1) + (int)(c - '0');
    c = getchar();
  }
  return tsqua;
}
char s[300010];
int n;
inline bool chk(int L, int R) {
  for (register int len = 1; len * 2 <= R - L + 1; len++)
    for (register int i = L; i + len * 2 <= R; i++)
      if (s[i] == s[i + len] && s[i + len] == s[i + len + len]) return 1;
  return 0;
}
inline long long GetAns(int L, int R) {
  if (L > R) return 0ll;
  long long ret = 0ll;
  if (R - L + 1 <= 10) {
    for (register int i = L; i <= R; i++)
      for (register int j = L + 1; j <= R; j++) ret += chk(i, j);
    return ret;
  }
  for (register int i = L; i <= R; i++)
    if (chk(L, i)) {
      int pos = L;
      for (; pos <= i; pos++)
        if (!chk(pos, i)) break;
      return GetAns(pos, R) + (long long)(R - i + 1) * (pos - L);
    }
}
int main(int argc, char const *argv[]) {
  ios::sync_with_stdio(false);
  scanf("%s", s + 1);
  n = strlen(s + 1);
  cout << GetAns(1, n);
  return 0;
}
