#include <bits/stdc++.h>
using namespace std;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  int n = (int)s.size();
  vector<int> vl(n + 1, n);
  long long ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    vl[i] = vl[i + 1];
    for (int k = 1; i + 2 * k < vl[i]; k++) {
      if (s[i] == s[i + k] && s[i + k] == s[i + 2 * k]) {
        vl[i] = i + 2 * k;
        break;
      }
    }
    ans += n - vl[i];
  }
  cout << ans << endl;
}
