#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  long long ans = 0;
  int n = s.size();
  vector<int> a(n + 1, n);
  for (int i = n - 1; i >= 0; --i) {
    a[i] = a[i + 1];
    for (int j = 1; j + j + i < n; ++j) {
      if (s[i] == s[j + i] && s[i] == s[j + i + j]) {
        a[i] = min(i + j + j, a[i]);
        break;
      }
    }
    ans += n - a[i];
  }
  cout << ans << '\n';
  return 0;
}
