#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
string s;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int ans = 0;
  cin >> s;
  int last = 0;
  int n = int(s.size());
  int atual = n;
  int vec[3 * (int)(1e5 + 10)];
  memset(vec, 0, sizeof vec);
  vec[n] = n;
  for (int i = int(s.size()) - 1; i >= 0; i--) {
    vec[i] = vec[i + 1];
    for (int tam = 1; i + 2 * tam < vec[i]; tam++) {
      if (i + (2 * tam) >= int(s.size())) break;
      if (s[i] == s[i + tam] and s[i] == s[i + (2 * tam)]) {
        vec[i] = i + (2 * tam);
        break;
      }
    }
    ans += n - vec[i];
  }
  cout << ans << "\n";
  return 0;
}
