#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin.exceptions(cin.failbit);
  string s;
  cin >> s;
  long long n = (int)(s).size();
  long long ans = 0;
  for (int i = 0; i < (n); ++i) {
    for (int j = i; j <= (n - 1); ++j) {
      bool found = false;
      for (int k = j - 1; k >= (i); --k) {
        int d = j - k;
        if (j - 2 * d >= i && s[j] == s[j - d] && s[j - d] == s[j - 2 * d]) {
          ans += n - j;
          found = true;
          break;
        }
      }
      if (found) break;
    }
  }
  cout << ans << endl;
  return 0;
}
