#include <bits/stdc++.h>
using namespace std;
int n;
string s;
int x[300002];
int main() {
  cin >> s;
  n = s.size();
  for (int i = 0; i < n; i++) {
    x[i] = -1;
    for (int j = i + 1; i + (j - i) * 2 < n; j++)
      if (s[i] == s[j] && s[j] == s[i + (j - i) * 2]) {
        x[i] = i + (j - i) * 2;
        break;
      }
  }
  int best = -1;
  long long ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (x[i] != -1 && (x[i] < best || best == -1)) best = x[i];
    if (best != -1) ans += n - best;
  }
  cout << ans << "\n";
  return 0;
}
