#include <bits/stdc++.h>
using namespace std;
char s[300000 + 10];
vector<char> a;
long long ans;
int isOk(int idx) {
  int val = 2000000000, k = a.size();
  for (int i = 0; i < k; i++)
    for (int j = i + 1; j < k; j++)
      for (int l = j + 1; l < k; l++)
        if (j - i == l - j && a[i] == a[j] && a[j] == a[l])
          val = min(val, idx + l);
  return val;
}
int main() {
  cin >> (s + 1);
  int n = strlen(s + 1);
  for (int i = 1; i <= n; i++) {
    a.clear();
    for (int j = i; j <= min(n, i + 7); j++) a.push_back(s[j]);
    int val = isOk(i);
    if (val == 2000000000) {
      if (i + 8 <= n) ans += 1LL * (n - i - 7);
    } else
      ans += 1LL * (n - val + 1);
  }
  cout << ans << '\n';
  return 0;
}
