#include <bits/stdc++.h>
using namespace std;
string s;
long long ans;
inline bool judge(string str) {
  for (int i = 0; i < str.length(); i++)
    for (int j = 1; i + j * 2 < str.length(); j++)
      if (str[i] == str[i + j] && str[i + j] == str[i + j * 2]) return true;
  return false;
}
int main() {
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    for (int j = 3; j <= min((int)s.length() - i, 8); j++)
      if (judge(s.substr(i, j))) ans++;
    ans += max(0, (int)s.length() - i - 8);
  }
  cout << ans;
  return 0;
}
