#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  long long cnt = 0;
  int n = s.size();
  for (int l = 0; l < n; l++) {
    for (int r = l + 2; r < n; r++) {
      bool good = false;
      for (int k = 1; r - 2 * k >= l; k++) {
        if (s[r] == s[r - k] && s[r - k] == s[r - 2 * k]) {
          good = true;
          break;
        }
      }
      if (good) {
        cnt += n - r;
        break;
      }
    }
  }
  cout << cnt;
  return 0;
}
