#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  cin >> s;
  long long int n = s.length(), ans = 0;
  for (long long int i = 0; i < n; i++) {
    long long int r = n;
    for (long long int j = i; j < i + 10 && j < n; j++) {
      for (long long int k = j + 2; k < i + 10 && k < n; k += 2) {
        if (s[j] == s[k] && s[j] == s[(j + k) / 2]) {
          r = min(r, k);
        }
      }
    }
    ans += (n - r);
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
