#include <bits/stdc++.h>
using namespace std;
const int INF = (int)(1e9 + 1337);
const long long LINF = (long long)(4e18);
const double EPS = (double)(1e-7);
int n;
int a[300010];
int d[300010];
long long do_solve() {
  int lid = -1;
  for (int i = 0; i < n; ++i) {
    d[i] = -1;
    for (int j = 1; i + 2 * j < n; ++j) {
      if (a[i] == a[i + j] && a[i] == a[i + 2 * j]) {
        d[i] = i + 2 * j;
        lid = i;
        break;
      }
    }
  }
  if (lid < 0) {
    return 0;
  }
  long long cur = d[lid];
  long long ans = n - cur;
  for (int i = lid - 1; i >= 0; --i) {
    if (d[i] != -1) {
      cur = min(cur, (long long)d[i]);
    }
    ans += n - cur;
  }
  return ans;
}
void solve() {
  string s;
  cin >> s;
  n = s.size();
  for (int i = 0; i < n; ++i) {
    a[i] = s[i] - '0';
  }
  cout << do_solve();
}
void stress() {
  n = 300000;
  mt19937 gen(1337);
  uniform_int_distribution<int> distr(0, 1);
  for (int i = 0; i < n; ++i) {
    a[i] = distr(gen);
  }
  cout << do_solve();
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}
