#include <bits/stdc++.h>
using namespace std;
long long a[1000000], i, x, ans[1000000], k, res;
string s;
int main() {
  cin >> s;
  s = "0" + s;
  for (i = 1; i <= 300003; i++) ans[i] = INT_MAX;
  for (i = 1; i <= s.length() - 1; i++) {
    for (k = 1; i + 2 * k < s.length(); k++)
      if ((s[i] == s[i + k]) && (s[i + k] == s[i + k + k])) {
        ans[i] = i + k + k;
        break;
      }
    x = i;
    while ((ans[x] < ans[x - 1]) && (x > 1)) {
      ans[x - 1] = ans[x];
      x--;
    }
  }
  for (i = 1; i <= 300001; i++)
    if (ans[i] != INT_MAX) res += s.length() - ans[i];
  cout << res;
  return 0;
}
