#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  ll ans = 0;
  for (int l = 0; l < n; l++) {
    if (l + 8 < n) ans += n - (l + 8);
    bool found = false;
    for (int r = l + 1; r < min(n, l + 8); r++) {
      for (int k = 1; 2 * k <= r - l; k++) {
        if (s[r] == s[r - k] && s[r - k] == s[r - 2 * k]) found = true;
      }
      ans += found;
    }
  }
  cout << ans << endl;
}
