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