#include <bits/stdc++.h>
using namespace std;
long long check(long long start, string &s) {
  long long mm = s.length();
  return mm;
}
signed main() {
  string s;
  getline(cin, s);
  long long ans = 0;
  long long i, j, k;
  long long t = 0;
  long long n = s.length();
  for (i = 0; i < n; i++) {
    long long val = n;
    for (j = i; j < min(n, i + 31); j++) {
      for (k = 1; j + 2 * k < n && k < 10; k++) {
        if (s[j] == s[j + k] && s[j] == s[j + 2 * k]) val = min(val, j + 2 * k);
      }
    }
    ans += (n - val);
  }
  cout << ans;
}
