#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++) {
      if (j + 2 < n and s[j] == s[j + 1] and s[j] == s[j + 2])
        R = min(R, j + 2);
      if (j + 4 < n and s[j] == s[j + 2] and s[j] == s[j + 4])
        R = min(R, j + 4);
      if (j + 6 < n and s[j] == s[j + 3] and s[j] == s[j + 6])
        R = min(R, j + 6);
      if (j + 8 < n and s[j] == s[j + 4] and s[j] == s[j + 8])
        R = min(R, j + 8);
    }
    ans += n - R;
  }
  cout << ans;
}
