#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int n = (int)s.size();
  vector<int> r(n, n);
  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= 10 && i + j * 2 < n; j++) {
      if (s[i] == s[i + j] && s[i] == s[i + 2 * j]) {
        r[i] = i + j * 2;
        break;
      }
    }
  }
  long long ans = 0;
  int mi = n;
  for (int i = n - 1; i >= 0; i--) {
    mi = min(r[i], mi);
    ans += n - mi;
  }
  cout << ans << endl;
  return 0;
}
