#include <bits/stdc++.h>
using namespace std;
char s[300005];
int main() {
  cin >> s;
  long long ans = 0;
  int len = strlen(s);
  int r = len;
  for (int i = len - 1; i >= 0; i--) {
    r = min(r, i + 9);
    for (int j = 1; i + 2 * j < r; j++) {
      if (s[i] == s[i + j] && s[i] == s[i + 2 * j]) {
        r = min(r, i + 2 * j);
        break;
      }
    }
    ans += (len - 1) - r + 1;
  }
  cout << ans << endl;
  return 0;
}
