#include <bits/stdc++.h>
using namespace std;
const int maxn = 300010;
const int inf = 0x3f3f3f3f;
int n, x, m;
char ch[maxn];
int main() {
  scanf("%s", ch);
  n = strlen(ch);
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    int flag = 0;
    for (int j = i + 2; j < n; ++j) {
      for (int d = i; d <= j; ++d) {
        for (int k = 1; d + 2 * k <= j; ++k) {
          if (ch[d] == ch[d + k] && ch[d + k] == ch[d + 2 * k]) {
            ans += n - j;
            flag = 1;
            break;
          }
        }
        if (flag) break;
      }
      if (flag) break;
    }
  }
  printf("%lld\n", ans);
}
