#include <bits/stdc++.h>
using namespace std;
int n, lst;
long long int ans;
string s;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> s;
  n = s.size();
  s = '?' + s;
  for (int i = 1; i <= n; ++i) {
    for (int j = i - 2, cnt = 0; j > lst && cnt < 1000; j -= 2, ++cnt) {
      if (s[i] == s[j] && s[(i + j) / 2] == s[i]) {
        lst = j;
        break;
      }
    }
    ans += lst;
  }
  cout << ans;
  return 0;
}
