#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 3;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  long long n = s.size(), ans = 0;
  for (long long i = 0; i < n; i++) {
    long long R = n;
    for (long long j = i; j < min(i + 9, n); j++) {
      for (long long k = 1; k <= 4; k++) {
        if (j + 2 * k < n and s[j] == s[j + k] and s[j] == s[j + 2 * k])
          R = min(R, j + 2 * k);
      }
    }
    ans += n - R;
  }
  cout << ans;
}
