#include <bits/stdc++.h>
using namespace std;
void fast() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}
vector<string> vec_splitter(string s) {
  s += ',';
  vector<string> res;
  while (!s.empty()) {
    res.push_back(s.substr(0, s.find(',')));
    s = s.substr(s.find(',') + 1);
  }
  return res;
}
void debug_out(vector<string> __attribute__((unused)) args,
               __attribute__((unused)) long long idx,
               __attribute__((unused)) long long LINE_NUM) {
  cerr << endl;
}
template <typename Head, typename... Tail>
void debug_out(vector<string> args, long long idx, long long LINE_NUM, Head H,
               Tail... T) {
  if (idx > 0)
    cerr << ", ";
  else
    cerr << "Line(" << LINE_NUM << ") ";
  stringstream ss;
  ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, LINE_NUM, T...);
}
double get_time() { return 1.0 * clock() / CLOCKS_PER_SEC; }
const long long MAX_SIZ = 10;
int32_t main() {
  string s;
  cin >> s;
  long long n = (long long)((s).size());
  long long res = 0;
  for (long long i = 0; i < n; i++) {
    for (long long j = i; j - i + 1 <= MAX_SIZ && j < n; j++) {
      bool ok = 0;
      for (long long k = i; k <= j; k++) {
        for (long long del = 1; k + del + del <= j; del++) {
          if (s[k] == s[k + del] && s[k] == s[k + del + del]) {
            ok = 1;
            break;
          }
        }
        if (ok) break;
      }
      res += ok;
    }
  }
  for (long long d = MAX_SIZ + 1; d <= n; d++) res += (n - d + 1);
  cout << res << '\n';
}
