#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  getline(cin, s);
  long long n = s.length();
  s = "0" + s;
  long long c = 0;
  for (int l = 1; l <= n; l++) {
    long long limit = l + 8;
    int minr = 1e9;
    for (int j = l; j <= std::min(limit, n); j++) {
      for (int k = 1; k <= 4; k++) {
        if (j + 2 * k <= n && s[j] == s[j + k] && s[j] == s[j + 2 * k]) {
          minr = min(minr, j + 2 * k);
        }
      }
    }
    if ((minr == 1e9) == false) c += n - minr + 1;
  }
  cout << c;
}
