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>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
const int MAXN = 5 + 300000;
const int INF = 1e6;
int mink[MAXN];
struct stree {
  vector<int> tree;
  function<int(int, int)> op;
  int sz;
  stree(int N, function<int(int, int)> f) : op(f) {
    assert(op);
    tree.resize((sz = N) << 2);
  }
  bool overlap(int qlow, int qhigh, int i, int j) {
    return !(qhigh < i || qlow > j);
  }
  int query(int& qlow, int& qhigh, int low, int high, int pos) {
    if (low >= qlow && high <= qhigh) return tree[pos];
    if (overlap(qlow, qhigh, low, ((low + high) >> 1)))
      return overlap(qlow, qhigh, 1 + ((low + high) >> 1), high)
                 ? op(query(qlow, qhigh, low, ((low + high) >> 1),
                            ((pos << 1) | 1)),
                      query(qlow, qhigh, 1 + ((low + high) >> 1), high,
                            (1 + ((pos << 1) | 1))))
                 : query(qlow, qhigh, low, ((low + high) >> 1),
                         ((pos << 1) | 1));
    return query(qlow, qhigh, 1 + ((low + high) >> 1), high,
                 (1 + ((pos << 1) | 1)));
  }
  int query(int i, int j) { return query(i, j, 0, sz - 1, 0); }
  int update(int low, int high, int pos, int& x, int& val) {
    if (x >= low && x <= high) {
      if (low == high) return tree[pos] = val;
      return tree[pos] =
                 op(update(low, ((low + high) >> 1), ((pos << 1) | 1), x, val),
                    update(1 + ((low + high) >> 1), high,
                           (1 + ((pos << 1) | 1)), x, val));
    }
    return tree[pos];
  }
  void update(int pos, int val) { update(0, sz - 1, 0, pos, val); }
};
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  string s;
  cin >> s;
  int n = (int)s.size();
  for (int i = 0; i < n; ++i) {
    mink[i] = INF;
    for (int k = 1; i + 2 * k < n; ++k) {
      if (s[i] == s[i + k] && s[i + k] == s[i + 2 * k]) {
        mink[i] = i + 2 * k;
        break;
      }
    }
  }
  stree st(n, [](int a, int b) -> int { return min(a, b); });
  for (int i = (int)0; i < (int)n; ++i) {
    st.update(i, mink[i]);
  }
  ll ans = 0LL;
  for (int i = 0; i < n; ++i) {
    int q = st.query(i, n - 1);
    if (q < n) {
      ans += 1LL * (n - q);
    }
  }
  cout << ans << '\n';
  return 0;
}