#include <bits/stdc++.h>
using namespace std;
long long read(long long x = 0) {
  int c, f = 1;
  for (c = getchar(); !isdigit(c); c = getchar())
    if (c == '-') f = -f;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
  return f * x;
}
long long a[300010], N, smin[300010], bd[300010];
vector<long long> pos[2];
char s[300010];
int main() {
  long long i, N, ans(0);
  scanf("%s", s + 1);
  N = strlen(s + 1);
  for (i = 1; i <= N; i++) {
    a[i] = s[i] - 0x30;
  }
  for (i = 1; i <= N; i++) {
    for (auto it = pos[a[i]].rbegin(); it != pos[a[i]].rend(); it++) {
      if (*it - (i - *it) > 0 and a[*it - (i - *it)] == a[i]) {
        bd[i] = *it - (i - *it);
        break;
      }
    }
    smin[i] = max(smin[i - 1], bd[i]);
    if (smin[i] > 0) ans += smin[i];
    pos[a[i]].emplace_back(i);
  }
  cout << ans;
  return 0;
}

### Prompt

Develop a solution in Cpp to the problem described below:

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.

### Response

```cpp
#include <bits/stdc++.h>
using namespace std;
long long read(long long x = 0) {
  int c, f = 1;
  for (c = getchar(); !isdigit(c); c = getchar())
    if (c == '-') f = -f;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
  return f * x;
}
long long a[300010], N, smin[300010], bd[300010];
vector<long long> pos[2];
char s[300010];
int main() {
  long long i, N, ans(0);
  scanf("%s", s + 1);
  N = strlen(s + 1);
  for (i = 1; i <= N; i++) {
    a[i] = s[i] - 0x30;
  }
  for (i = 1; i <= N; i++) {
    for (auto it = pos[a[i]].rbegin(); it != pos[a[i]].rend(); it++) {
      if (*it - (i - *it) > 0 and a[*it - (i - *it)] == a[i]) {
        bd[i] = *it - (i - *it);
        break;
      }
    }
    smin[i] = max(smin[i - 1], bd[i]);
    if (smin[i] > 0) ans += smin[i];
    pos[a[i]].emplace_back(i);
  }
  cout << ans;
  return 0;
}

```