#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;
  int n = ((int)(s).size());
  vector<int> dp(n + 1);
  dp[n] = n;
  long long int ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    dp[i] = dp[i + 1];
    for (int j = i + 2; j < dp[i]; j += 2) {
      if (s[i] == s[j] && s[i] == s[(i + j) / 2]) {
        dp[i] = j;
        break;
      }
    }
    ans += n - dp[i];
  }
  cout << ans << endl;
  return 0;
}
