#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int maxn = 2e5 + 5;
const long long mod = 1e9 + 7;
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  string s;
  cin >> s;
  long long ans = 0;
  int n = s.size();
  for (int i = n - 1; i >= 0; --i) {
    for (int k = 1; i + 2 * k < n; ++k)
      if (s[i] == s[i + k] && s[i] == s[i + 2 * k]) {
        n = i + 2 * k;
        break;
      }
    ans += s.size() - n;
  }
  cout << ans << '\n';
  return 0;
}
