#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int ra[s.length()];
  for (int i = 0; i < s.length(); i++) {
    ra[i] = s.length();
    for (int j = 1; j <= 4; j++) {
      if (i + j * 2 < s.length() && s[i] == s[i + j] && s[i] == s[i + j * 2]) {
        ra[i] = i + j * 2;
        break;
      }
    }
  }
  long long ans = 0;
  for (int i = s.length() - 2; i >= 0; i--) {
    ra[i] = min(ra[i], ra[i + 1]);
    ans += s.length() - ra[i];
  }
  printf("%lld\n", ans);
  return 0;
}
