#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  cin >> s;
  long long n = s.length();
  long long cnt = 0, pst = n;
  bool f = 0, bf;
  for (long long i = n - 3; i >= 0; i--) {
    for (long long j = i + 2; j < n; j += 2) {
      if (s[i] == s[j] && s[i] == s[(i + j) / 2]) {
        if (j < pst) {
          pst = j;
        }
        break;
      }
    }
    cnt += n - pst;
  }
  cout << cnt << '\n';
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int TESTS = 1;
  while (TESTS--) {
    solve();
  }
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
