#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 = 1 << 28;
constexpr long long mod = 1000000007LL;
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  long long res = 0;
  for (int left = 0; left < n; left++) {
    int right = left + 2;
    if (right > n) break;
    for (; right < n and right < left + 15; right++) {
      bool flag = false;
      for (int i = left; i <= right; i++) {
        for (int len = 1; len < n; len++) {
          if (i + len * 2 > right) break;
          if (s[i] == s[i + len] and s[i + len] == s[i + len * 2]) {
            flag = true;
            break;
          }
        }
        if (flag) break;
      }
      res += flag;
    }
    res += n - right;
  }
  cout << res << endl;
  return 0;
}
