#include <bits/stdc++.h>
using namespace std;
string s;
int tab[1000007];
long long x, a, b, c, p, wyn;
int main() {
  cin >> s;
  int dlug = s.size();
  for (int i = 0; i < s.size(); i++) {
    for (int j = i + 2; j < s.size(); j++) {
      x = 0;
      for (int k = 1; j - 2 * k >= i; k++) {
        a = (int)s[j];
        b = (int)s[j - k];
        c = (int)s[j - 2 * k];
        if (a == b && b == c) {
          wyn += (s.size() - j);
          x = 1;
          break;
        }
      }
      if (x == 1) {
        break;
      }
    }
  }
  cout << wyn;
  return 0;
}
