#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long inf = 1e15;
const long long N = 3e5 + 10;
int main() {
  string s;
  cin >> s;
  long long ans = 0;
  long long n = s.size();
  std::vector<long long> maxr(n + 1, n);
  for (long long l = n - 1; l >= 0; l--) {
    maxr[l] = maxr[l + 1];
    for (long long k = 1; l + k + k < maxr[l]; k++) {
      if (s[l] == s[l + k] and s[l] == s[l + k + k]) {
        maxr[l] = l + k + k;
        break;
      }
    }
    ans += n - maxr[l];
  }
  cout << ans;
  return 0;
}
