#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1, -1, 1, -1, 0, 0, -1, 1};
const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9 + 7;
const int maxn = (int)2e5 + 5;
const int LOGN = 20;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  cin >> s;
  int n = s.size();
  long long cnt = 0;
  for (int i = 0; i < n; i++) {
    int to = n;
    for (int j = i; j < to; j++) {
      int k = 1;
      while (i + 2 * k < to) {
        if (s[j] == s[j + k] && s[j] == s[j + 2 * k]) {
          to = min(to, j + 2 * k);
        }
        k++;
      }
    }
    cnt += n - to;
  }
  cout << cnt;
  return 0;
}
