#include <bits/stdc++.h>
class Binary {
 private:
  std::vector<short> bits;

 public:
  Binary(const std::string& str) {
    for (int i = 0; i < str.length(); i++) {
      if (str[str.length() - 1 - i] == '0')
        bits.push_back(0);
      else
        bits.push_back(1);
    }
  }
  Binary(int number, int len = 0) {
    for (int i = 0; i < len || (len == 0 && number > 0); i++) {
      bits.push_back(number & 1);
      number /= 2;
    }
  }
  inline int getLength() const { return bits.size(); }
  inline short& operator[](int index) { return bits[index]; }
  inline short operator[](int index) const { return bits[index]; }
  friend std::ostream& operator<<(std::ostream& output, const Binary& bin) {
    for (int i = 0; i < bin.getLength(); i++) {
      output << bin[bin.getLength() - 1 - i];
    }
  }
  ~Binary() = default;
};
bool checkTriple(const Binary& bin) {
  bool isTriple = false;
  for (int head = 0; head <= bin.getLength() - 3; head++) {
    int maxInterval = (bin.getLength() - head - 1) / 2;
    for (int interval = 1; interval <= maxInterval; interval++) {
      if (bin[head] == bin[head + interval] &&
          bin[head] == bin[head + 2 * interval]) {
        isTriple = true;
        break;
      }
    }
    if (isTriple) break;
  }
  return isTriple;
}
int maxNonTripleLength() {
  int len = 3;
  bool allTriple;
  do {
    allTriple = true;
    len++;
    for (int num = 0; num < std::pow(2, len); num++) {
      Binary bin(num, len);
      allTriple &= checkTriple(bin);
      if (!allTriple) break;
    }
  } while (!allTriple);
  return len - 1;
}
int main(int argc, char const* argv[]) {
  std::string bstr;
  int minCheckLen = 3;
  int maxCheckLen = 8;
  std::cin >> bstr;
  long long res = 0;
  for (int head = 0; head + minCheckLen <= bstr.length(); head++) {
    int left = minCheckLen;
    int right = std::min(maxCheckLen, int(bstr.length()) - head);
    const int rightmost = right;
    do {
      int mid = (left + right) / 2;
      Binary bin = Binary(bstr.substr(head, mid));
      bool hasTriple = checkTriple(bin);
      if (hasTriple)
        right = mid;
      else
        left = mid + 1;
    } while (left < right);
    int minlen;
    if (right < rightmost || checkTriple(Binary(bstr.substr(head, left)))) {
      minlen = left;
    } else {
      minlen = maxCheckLen + 1;
    }
    if (head + minlen - 1 < bstr.length()) {
      res += bstr.length() - (head + minlen - 1);
    }
  }
  std::cout << res;
  return 0;
}
