#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = (int)s.length();
  long long ans = 0;
  for (int l = 0; l < n; l++) {
    int maxxr = 999999999;
    for (int j = l; j <= l + 15; j++) {
      for (int k = 1; k <= 15; k++) {
        if (s[j] == s[j + k] && s[j] == s[j + 2 * k]) {
          maxxr = min(maxxr, j + 2 * k);
        }
      }
    }
    if (maxxr < n) ans += (n - maxxr);
  }
  cout << ans << endl;
  return 0;
}
