#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y, long long z) {
  long long ret = 1;
  while (y > 0) {
    if (y & 1) ret = (ret * x) % z;
    x = (x * x) % z;
    y >>= 1;
  }
  return ret;
}
const long long MX = 3e5 + 5;
string s;
int main() {
  cin >> s;
  long long n = s.size(), tot = 0, pre = n, curr;
  for (long long i = n - 1; i >= 0; --i) {
    curr = pre;
    for (long long k = 1; i + 2 * k < curr; ++k) {
      if (s[i] == s[i + k] && s[i + k] == s[i + 2 * k]) {
        curr = min(curr, i + 2 * k);
        break;
      }
    }
    pre = curr;
    tot += (n - curr);
  }
  printf("%lld\n", tot);
  return 0;
}
