#include <bits/stdc++.h>
using namespace std;
template <class _Tp>
void ckmax(_Tp &a, _Tp b) {
  if (a < b) a = b;
}
template <class _Tp>
void ckmin(_Tp &a, _Tp b) {
  if (a > b) a = b;
}
template <class _Tp>
_Tp gcd(_Tp a, _Tp b) {
  return (b == 0) ? (a) : (gcd(b, a % b));
}
int read() {
  char ch = getchar();
  bool f = 1;
  int x = 0;
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') f = 0, ch = getchar();
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + (ch & 15);
    ch = getchar();
  }
  return f ? x : -x;
}
const int inf = 1000000000;
const long long Inf = 1000000000000000000ll;
char s[300050];
int len, res;
long long ans;
int main() {
  scanf("%s", s + 1);
  int len = strlen(s + 1);
  for (int i = len, res = inf; i >= 1; --i) {
    for (int j = 1; i + j * 2 <= len; ++j) {
      if (s[i] == s[i + j] && s[i] == s[i + j * 2]) {
        res = min(res, i + 2 * j);
        break;
      }
    }
    if (res != inf) ans += len - res + 1;
  }
  printf("%lld\n", ans);
  return 0;
}
