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;
}
long long solve(const std::string& bstr) {
  int minCheckLen = 3;
  int maxCheckLen = 8;
  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);
    }
  }
  return res;
}
long long solve2(const std::string& bstr) {
  long long ans = 0;
  int len = bstr.length();
  int *q[2], qt[2], *fin;
  q[0] = new int[len];
  q[1] = new int[len];
  fin = new int[len];
  qt[0] = qt[1] = 0;
  for (int i = 0; i < len; i++) {
    fin[i] = 0;
    q[0][qt[0]++] = i;
  }
  int cur = 0, step = 1;
  while (qt[cur]) {
    int o = !cur;
    for (int qh = 0; qh < qt[cur]; qh++) {
      int f = q[cur][qh];
      if (f + step < len) {
        if (step % 2 == 0 && bstr[f] == bstr[f + step] &&
            bstr[f] == bstr[f + step / 2]) {
          fin[f + step] = 1;
        }
        if (!fin[f + step])
          q[o][qt[o]++] = f;
        else
          ans += len - f - step;
      }
    }
    qt[cur] = 0;
    cur = !cur;
    step++;
  }
  delete[] q[0];
  delete[] q[1];
  delete[] fin;
  return ans;
}
long long solve3(const std::string& bstr) {
  int minLen = 3, maxLen = 8;
  int len = bstr.length();
  long long res = 0;
  int* minTail = new int[len];
  for (int i = 0; i + minLen - 1 < len; i++) {
    if (bstr[i] == bstr[i + 2] && bstr[i] == bstr[i + 1]) {
      minTail[i] = i + 2;
    } else if (i + 4 < len && bstr[i] == bstr[i + 4] &&
               bstr[i] == bstr[i + 2]) {
      minTail[i] = i + 4;
    } else if (i + 6 < len && bstr[i] == bstr[i + 6] &&
               bstr[i] == bstr[i + 3]) {
      minTail[i] = i + 6;
    } else if (i + 8 < len) {
      minTail[i] = i + 8;
    } else
      minTail[i] = -1;
  }
  int tail = -1;
  for (int i = len - minLen; i >= 0; i--) {
    if (minTail[i] > 0) {
      if (tail < 0)
        tail = minTail[i];
      else
        tail = std::min(tail, minTail[i]);
    }
    if (tail > 0) {
      res += len - tail;
    }
  }
  delete[] minTail;
  return res;
}
int main(int argc, char const* argv[]) {
  std::string bstr;
  std::cin >> bstr;
  long long res = solve3(bstr);
  std::cout << res;
  return 0;
}