#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const long long INF = std::numeric_limits<long long>::max();
const int MX = 100101;
const long double PI =
    3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270L;
template <typename T>
pair<T, T> operator+(const pair<T, T> &a, const pair<T, T> &b) {
  return pair<T, T>(a.first + b.first, a.second + b.second);
}
template <typename T>
pair<T, T> operator-(const pair<T, T> &a, const pair<T, T> &b) {
  return pair<T, T>(a.first - b.first, a.second - b.second);
}
template <typename T>
T operator*(const pair<T, T> &a, const pair<T, T> &b) {
  return (a.first * b.first + a.second * b.second);
}
template <typename T>
T operator^(const pair<T, T> &a, const pair<T, T> &b) {
  return (a.first * b.second - a.second * b.first);
}
std::string s;
bool check(int l, int r) {
  for (int m = l + 1; m < r; ++m) {
    for (int d = 1;; ++d) {
      if (m - d >= l and m + d <= r) {
        if (s[m - d] == s[m] and s[m] == s[m + d]) return true;
      } else
        break;
    }
  }
  return false;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> s;
  long long ats = 0;
  int N = s.size();
  for (int i = 0; i < N; ++i) {
    for (int j = 2; j < 9 and i + j < N; ++j)
      if (check(i, i + j)) ats++;
    ats += max(0, N - (i + 8) - 1);
  }
  printf("%lld\n", ats);
}
