#include <bits/stdc++.h>
using namespace std;
long long n, maxl = -1;
char a[300010];
long long ans;
int main() {
  scanf(" %s", a);
  n = strlen(a);
  for (long long i = 0; i < n; i++) {
    for (long long j = i + 2; j < min(i + 9, n); j += 2) {
      if (a[i] == a[j] && a[i] == a[(i + j) / 2]) {
        bool flag = 0;
        for (int _a = i + 1; _a <= j; _a++)
          for (int b = _a + 1; 2 * b - _a <= j; b++)
            if (a[_a] == a[b] && a[b] == a[2 * b - _a]) flag = 1;
        if (flag) break;
        ans += (i - maxl) * (n - j);
        maxl = max(maxl, i);
        break;
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}
