Problem: Toad Rash has a binary string s. A binary string consists only of zeros and ones.

Let n be the length of s.

Rash needs to find the number of such pairs of integers l, r that 1 ≤ l ≤ r ≤ n and there is at least one pair of integers x, k such that 1 ≤ x, k ≤ n, l ≤ x < x + 2k ≤ r, and s_x = s_{x+k} = s_{x+2k}.

Find this number of pairs for Rash.

Input

The first line contains the string s (1 ≤ |s| ≤ 300 000), consisting of zeros and ones.

Output

Output one integer: the number of such pairs of integers l, r that 1 ≤ l ≤ r ≤ n and there is at least one pair of integers x, k such that 1 ≤ x, k ≤ n, l ≤ x < x + 2k ≤ r, and s_x = s_{x+k} = s_{x+2k}.

Examples

Input


010101


Output


3


Input


11001100


Output


0

Note

In the first example, there are three l, r pairs we need to count: 1, 6; 2, 6; and 1, 5.

In the second example, there are no values x, k for the initial string, so the answer is 0.

Solution (in CPP):

Solution:
#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;
}