#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  string s;
  cin >> s;
  long long int ans = 0;
  for (int i = 0; i < s.length(); i++) {
    long long int barr = s.length();
    for (int start = i; start < barr; start++) {
      for (int k = 1; start + 2 * k < barr; k++) {
        if (s[start] == s[start + k] && s[start + k] == s[start + 2 * k]) {
          barr = start + 2 * k;
          break;
        }
      }
    }
    ans += (long long int)s.length() - (long long int)barr;
  }
  cout << ans << endl;
}
