#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e5 + 10;
int n, m, a[maxn];
string s;
vector<int> v;
int main() {
  ios::sync_with_stdio(false);
  cin >> s;
  n = s.size();
  long long cou = 0;
  v.resize(n + 5, n);
  for (int i = n - 1; i >= 0; i--) {
    v[i] = v[i + 1];
    for (int j = 1; 2 * j + i < v[i]; j++) {
      if (s[i] == s[i + 2 * j] && s[i] == s[i + j]) v[i] = i + 2 * j;
    }
    cou += n - v[i];
  }
  cout << cou << endl;
  return 0;
}
