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;
#pragma optimize(2)
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target( \
    "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
const int inf = 0x7FFFFFFF;
template <class T>
inline void MAX(T &x, T y) {
  if (y > x) x = y;
}
template <class T>
inline void MIN(T &x, T y) {
  if (y < x) x = y;
}
template <class T>
inline void rd(T &x) {
  x = 0;
  char o, f = 1;
  while (o = getchar(), o < 48)
    if (o == 45) f = -f;
  do x = (x << 3) + (x << 1) + (o ^ 48);
  while (o = getchar(), o > 47);
  x *= f;
}
template <class T>
void wt(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) wt(x / 10);
  putchar('0' + x % 10);
}
const long long llinf = 4223372036854775807;
const long long mod = (0 ? 1000000007 : 998244353);
const long long mod2 = 999998639;
const long long m1 = 998244353;
const long long m2 = 1000001011;
const long long pr = 233;
const double eps = 1e-7;
const long long maxm = 1;
const long long maxn = 510000;
string tmp;
long long dis[310000];
void work() {
  cin >> tmp;
  long long n = tmp.size();
  for (long long i = 0; i < n; i++) dis[i] = llinf;
  dis[n] = llinf;
  for (long long i = n - 1; i >= 0; i--)
    for (long long k = 1; i + (k << 1) < min(n, dis[i + 1]); k++)
      if (tmp[i] == tmp[i + k] && tmp[i] == tmp[i + (k << 1)]) {
        dis[i] = i + (k << 1);
        break;
      }
  for (long long i = n - 2; i >= 0; i--) MIN(dis[i], dis[i + 1]);
  long long ans = 0;
  for (long long i = 0; i < n; i++)
    if (dis[i] == llinf)
      continue;
    else
      ans += n - dis[i];
  cout << ans << endl;
}
signed main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  while (t--) {
    work();
  }
  return 0;
}