#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 5;
string s;
int n;
void ReadInput() {
  cin >> s;
  n = s.length();
}
void Solve() {
  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;
    ans += (long long)n - vl[i];
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  ReadInput();
  Solve();
}
