#include <bits/stdc++.h>
using namespace std;
#pragma optimize(2)
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
const int inf = 0x7FFFFFFF;
template <class T>
inline void MAX(T &x, T y) {
  if (y > x) x = y;
}
template <class T>
inline void MIN(T &x, T y) {
  if (y < x) x = y;
}
template <class T>
inline void rd(T &x) {
  x = 0;
  char o, f = 1;
  while (o = getchar(), o < 48)
    if (o == 45) f = -f;
  do x = (x << 3) + (x << 1) + (o ^ 48);
  while (o = getchar(), o > 47);
  x *= f;
}
template <class T>
void wt(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) wt(x / 10);
  putchar('0' + x % 10);
}
const long long llinf = 4223372036854775807;
const long long mod = (0 ? 1000000007 : 998244353);
const long long mod2 = 999998639;
const long long m1 = 998244353;
const long long m2 = 1000001011;
const long long pr = 233;
const double eps = 1e-7;
const long long maxm = 1;
const long long maxn = 510000;
string tmp;
long long dis[310000];
void work() {
  cin >> tmp;
  long long n = tmp.size();
  for (long long i = 0; i < n; i++) dis[i] = llinf;
  dis[n] = llinf;
  for (long long i = n - 1; i >= 0; i--)
    for (long long k = 1; i + (k << 1) < min(n, dis[i + 1]); k++)
      if (tmp[i] == tmp[i + k] && tmp[i] == tmp[i + (k << 1)]) {
        dis[i] = i + (k << 1);
        break;
      }
  for (long long i = n - 2; i >= 0; i--) MIN(dis[i], dis[i + 1]);
  long long ans = 0;
  for (long long i = 0; i < n; i++)
    if (dis[i] == llinf)
      continue;
    else
      ans += n - dis[i];
  cout << ans << endl;
}
signed main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  while (t--) {
    work();
  }
  return 0;
}
