#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  long long i, j, ans = 0, k, n = s.size();
  for (i = 0; i < n; i++) {
    long long idx = 1000000007, f = 0;
    for (j = i; j < min(i + 20, n); j++) {
      for (k = j + 1; k < min(j + 20, n); k++) {
        if (s[j] == s[k] && s[k] == s[k + k - j] && k + k - j < n) {
          idx = min(k + k - j, idx);
          f = 1;
        }
      }
    }
    if (idx != 1000000007) ans += (n - idx);
  }
  cout << ans;
  return 0;
}
