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;
void fastIO() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
template <typename T, typename U>
inline void mnze(T &x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
inline void mxze(T &x, U y) {
  if (x < y) x = y;
}
void _scan(int &x) { scanf("%d", &x); }
void _scan(long long &x) { scanf("%lld", &x); }
void _scan(double &x) { scanf("%lf", &x); }
void _scan(char &x) { scanf(" %c", &x); }
void _scan(char *x) { scanf("%s", x); }
void scan() {}
template <typename T, typename... U>
void scan(T &head, U &...tail) {
  _scan(head);
  scan(tail...);
}
template <typename T>
void _dbg(const char *sdbg, T h) {
  cerr << sdbg << "=" << h << "\n";
}
template <typename T, typename... U>
void _dbg(const char *sdbg, T h, U... t) {
  while (*sdbg != ',') cerr << *sdbg++;
  cerr << "=" << h << ",";
  _dbg(sdbg + 1, t...);
}
int getbit(int msk, int i) { return (msk >> i) & 1; }
int dp[1000][10];
bool bad(int msk, int n) {
  int &ret = dp[msk][n];
  if (ret != -1) return ret;
  for (int i = 0; i < (int)n; i++) {
    for (int k = 1; i + 2 * k < (int)n; k++) {
      if (getbit(msk, i) == getbit(msk, i + k) &&
          getbit(msk, i) == getbit(msk, i + 2 * k))
        return (ret = 0);
    }
  }
  return (ret = 1);
}
const int MAXN = 3e5 + 5;
long long n;
char s[MAXN];
int main() {
  memset(dp, -1, sizeof(dp));
  scan(s);
  n = strlen(s);
  long long ans = n * (n - 1) / 2;
  for (int l = 0; l < (int)n; l++) {
    int msk = s[l] - '0';
    for (int r = l + 1; r < min((int)n, l + 9); r++) {
      msk = (msk << 1) + (s[r] - '0');
      ans -= bad(msk, r - l + 1);
    }
  }
  printf("%lld\n", ans);
}