#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  vector<pair<long long, long long> > arr;
  long long n = s.length();
  for (int i = 0; i < n; i++) {
    for (int j = 1; i + (2 * j) < n; j++) {
      if (s[i] == s[i + j] && s[i] == s[i + (2 * j)]) {
        arr.push_back(make_pair(i + (2 * j), i));
        break;
      }
    }
  }
  sort(arr.begin(), arr.end());
  long long cnt = 0;
  for (int i = 0, j = 0; i < n; i++) {
    while (j < arr.size() && arr[j].second < i) j++;
    if (j == arr.size()) break;
    cnt += (n - arr[j].first);
  }
  cout << cnt << endl;
}
