#include <bits/stdc++.h>
using namespace std;
const int MAXN = 3e5 + 5;
int minhold[MAXN];
long long ans;
int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    minhold[i] = 1e9;
    for (int k = 1; i + 2 * k < s.length(); k++) {
      if (s[i] == s[i + k] && s[i + k] == s[i + 2 * k]) {
        minhold[i] = i + 2 * k;
        break;
      }
    }
  }
  int tempmin = 1e9;
  for (int i = s.length() - 1; i >= 0; i--) {
    tempmin = min(tempmin, minhold[i]);
    if (tempmin < s.length()) {
      ans += (s.length() - tempmin);
    }
  }
  cout << ans << endl;
}
