#include <bits/stdc++.h>
using namespace std;
using LL = long long;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  int n = s.size();
  LL ans = 0;
  for (int l = 0, r = 0; l < n && r < n; l++) {
    for (bool valid = false; r < n; r++) {
      for (int x = l; !valid && x <= r; x++) {
        for (int k = 1; !valid && x + 2 * k <= r; k++) {
          if (s[x] == s[x + k] && s[x] == s[x + 2 * k]) {
            valid = true;
          }
        }
      }
      if (valid) break;
    }
    ans += n - r;
  }
  cout << ans << endl;
  return 0;
}
