#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
char str[maxn];
int d[maxn];
int main() {
  scanf("%s", str + 1);
  int n = strlen(str + 1);
  for (int i = 1; i <= n; i++)
    for (int j = 1; i + j * 2 <= n; j++) {
      if (str[i] == str[i + j] && str[i + j] == str[i + 2 * j]) {
        d[i] = i + j * 2;
        break;
      }
    }
  long long ans = 0, r = 1e9;
  for (int i = n; i >= 1; i--) {
    if (d[i]) {
      r = min(r, (long long)d[i]);
    }
    if (r != 1e9) ans += n - r + 1;
  }
  cout << ans;
  return 0;
}
