#include <bits/stdc++.h>
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
constexpr long long mod = 998244353LL;
using namespace std;
bool check(string& s) {
  for (int len = 1; len <= s.size(); len++) {
    for (int i = 0; i < s.size(); i++) {
      if (i + len + len >= s.size()) break;
      if (s[i] == s[i + len] and s[i + len] == s[i + len + len]) return true;
    }
  }
  return false;
}
int main() {
  string s;
  cin >> s;
  int n = s.size();
  long long res = 0;
  for (int left = 0; left < n; left++) {
    int right = left;
    for (; right < min(n, left + 11); right++) {
      string t = s.substr(left, right - left + 1);
      if (check(t)) res++;
    }
    res += n - right;
  }
  cout << res << endl;
  return 0;
}
