#include <bits/stdc++.h>
using namespace std;
long long n, ans;
string s;
int main() {
  cin >> s;
  n = s.size();
  for (int i = 1, l = 0; i <= n; i++) {
    for (int j = 1; i - j - j >= l; j++) {
      if (s[i - 1] == s[i - j - 1] && s[i - 1] == s[i - j - j - 1]) {
        l = i - j - j;
      }
    }
    ans += l;
  }
  cout << ans << endl;
  return 0;
}
