#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 3e5 + 7;
const long long MOD = 1e9 + 7;
char str[N];
int n;
int main() {
  scanf("%s", str);
  n = strlen(str);
  long long ans = 0;
  for (int i = 0; str[i]; ++i) {
    int mn = MOD;
    for (int j = i; j < min(i + 9, n); ++j) {
      for (int k = 1;; ++k) {
        if (j + 2 * k >= min(i + 9, n)) break;
        if (str[j] == str[j + k] && str[j] == str[j + 2 * k]) {
          mn = min(j + 2 * k, mn);
        }
      }
    }
    if (mn != MOD) ans += n - mn;
  }
  cout << ans << endl;
  return 0;
}
