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;
inline long long read() {
  char ch = getchar();
  long long s = 0, w = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    s = s * 10 + ch - '0';
    ch = getchar();
  }
  return s * w;
}
int z[300010][2];
deque<int> Q[2];
char s[300010];
int v[300010], n;
int r[300010];
int vis[2];
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (register int i = 1; i <= n; i++) v[i] = s[i] - '0';
  for (register int i = 1; i <= n; i++) r[i] = n + 1;
  for (register int i = n; i >= 1; i--) {
    if (!vis[v[i]]) {
      vis[v[i]] = 1;
      z[i][v[i]] = 1;
    } else {
      int tmp = Q[v[i]].size();
      for (register int j = 0; j < tmp; j++) {
        int x = Q[v[i]][j];
        if (z[2 * x - i][v[i]]) {
          r[i] = 2 * x - i;
          while (!Q[v[i]].empty() && Q[v[i]].back() >= x) {
            z[Q[v[i]].back()][v[i]] = 1;
            Q[v[i]].pop_back();
          }
          break;
        }
      }
      Q[v[i]].push_front(i);
      z[i][v[i]] = 1;
    }
  }
  for (register int i = n - 1; i >= 1; i--) r[i] = min(r[i], r[i + 1]);
  long long ans = 0;
  for (register int i = 1; i <= n; i++) ans += 1LL * (n - r[i] + 1);
  printf("%I64d\n", ans);
  return 0;
}