#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
constexpr auto MOD = 1000000007LL;
constexpr auto LINF = (1LL << 60);
constexpr auto INF = 2147483647LL;
constexpr auto PI = 3.1415926535897932384626433;
constexpr auto EPS = 1E-9;
template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> p) {
  out << p.first << ' ' << p.second;
  return out;
}
template <typename T1, typename T2>
istream &operator>>(istream &in, pair<T1, T2> &p) {
  in >> p.first >> p.second;
  return in;
}
template <typename T>
istream &operator>>(istream &in, vector<T> &v) {
  for (auto &x : v) in >> x;
  return in;
}
template <typename T>
ostream &operator<<(ostream &out, vector<T> v) {
  for (int i = 0; i < v.size(); i++)
    out << v[i] << (i + 1 == v.size() ? '\n' : ' ');
  out.flush();
  return out;
}
int rr[300010];
ll res;
int main() {
  ios_base::sync_with_stdio(false);
  string str;
  cin >> str;
  int n = str.length();
  fill(rr, rr + 300010, INF);
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 1; j <= 5; j++) {
      if (i + 2 * j >= n) break;
      if (str[i] == str[i + j] && str[i] == str[i + 2 * j]) {
        rr[i] = i + 2 * j;
        break;
      }
    }
    rr[i] = min(rr[i + 1], rr[i]);
    if (rr[i] < n) {
      res += n - rr[i];
    }
  }
  cout << res << endl;
  return 0;
}
