#include <bits/stdc++.h>
using namespace std;
const long long N = 300007;
const long long M = 200001;
const long long INF = 0x3f3f3f;
const double inf = 2e9 + 7;
const double Pi = acos(-1);
const long long MOD = 100000007;
const double eps = 1e-7;
long long n, m;
char s[N];
int main() {
  while (~scanf("%s", s + 1)) {
    long long l = strlen(s + 1);
    long long pos = 0;
    long long pre = 0;
    long long ans = 0;
    for (long long j = 1; j <= l; j++) {
      for (long long i = j; i <= l; i++) {
        int f = 0;
        for (long long k = 1; i - 2 * k >= j; k++) {
          if (s[i] == s[i - k] && s[i] == s[i - 2 * k]) {
            long long tmp = (l - i + 1);
            ans += tmp;
            f = 1;
            break;
          }
        }
        if (f) break;
      }
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
