#include <bits/stdc++.h>
using namespace std;
int n, m;
char s[404040];
int main() {
  scanf("%s", s);
  int len = strlen(s);
  long long ans = 0, mx = len + 1;
  for (int i = len - 1; i >= 0; --i) {
    for (int j = 1; i + 2 * j <= len; ++j) {
      if (s[i] == s[i + j] && s[i] == s[i + 2 * j]) {
        mx = min(mx, 1ll * (i + 2 * j));
        break;
      }
    }
    ans += max(len - mx, 0ll);
  }
  cout << ans;
}
