#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  long long int ans = 0, cc;
  long long int l = s.length();
  long long int prev = l;
  for (long long int i = l - 3; i >= 0; i--) {
    cc = l - prev;
    for (long long int j = i + 1; j < i + 5 && (2 * j - i) < l; j++) {
      if (s[i] == s[j] && s[j] == s[(2 * j) - i] && (2 * j) - i < prev) {
        cc = l - ((2 * j) - i);
        prev = (2 * j) - i;
        break;
      }
    }
    ans += cc;
  }
  cout << ans << endl;
  return 0;
}
