#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
const ll inf = (1e18);
const ll mod = 1000000007;
const vector<int> dy = {-1, 0, 1, 0}, dx = {0, -1, 0, 1};
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll c, ll d) { return c / GCD(c, d) * d; }
struct __INIT {
  __INIT() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} __init;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
void debag(const vector<T> &a) {
  cerr << "debag :";
  for (auto v : a) cerr << v << " ";
  cerr << "\n";
}
template <class T>
void print(const vector<T> &a) {
  for (auto v : a) cout << v << " ";
  cout << "\n";
}
void solve() {
  string s;
  cin >> s;
  ll n = s.size();
  ll res = 0;
  for (int i = 0; i < n; i++) {
    string tmp = {};
    for (int j = i; (j - i) <= 10 && j < n; j++) {
      tmp.push_back(s[j]);
      bool ok = true;
      for (int k = 0; k < int(tmp.size()); k++) {
        int d = 1;
        while (1) {
          if (k + 2 * d >= int(tmp.size())) break;
          if (tmp[k] == tmp[k + d] && tmp[k + d] == tmp[k + 2 * d]) {
            ok = false;
            break;
          }
          d++;
        }
        if (!ok) break;
      }
      if (ok)
        res++;
      else {
        break;
      }
    }
  }
  ll ma = (n + 1) * n / 2;
  cout << ma - res << "\n";
}
int main() {
  int t = 1;
  while (t--) solve();
}

### Prompt

Please provide a Cpp coded solution 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>
#pragma GCC optimize("O3")
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
const ll inf = (1e18);
const ll mod = 1000000007;
const vector<int> dy = {-1, 0, 1, 0}, dx = {0, -1, 0, 1};
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll c, ll d) { return c / GCD(c, d) * d; }
struct __INIT {
  __INIT() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} __init;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
void debag(const vector<T> &a) {
  cerr << "debag :";
  for (auto v : a) cerr << v << " ";
  cerr << "\n";
}
template <class T>
void print(const vector<T> &a) {
  for (auto v : a) cout << v << " ";
  cout << "\n";
}
void solve() {
  string s;
  cin >> s;
  ll n = s.size();
  ll res = 0;
  for (int i = 0; i < n; i++) {
    string tmp = {};
    for (int j = i; (j - i) <= 10 && j < n; j++) {
      tmp.push_back(s[j]);
      bool ok = true;
      for (int k = 0; k < int(tmp.size()); k++) {
        int d = 1;
        while (1) {
          if (k + 2 * d >= int(tmp.size())) break;
          if (tmp[k] == tmp[k + d] && tmp[k + d] == tmp[k + 2 * d]) {
            ok = false;
            break;
          }
          d++;
        }
        if (!ok) break;
      }
      if (ok)
        res++;
      else {
        break;
      }
    }
  }
  ll ma = (n + 1) * n / 2;
  cout << ma - res << "\n";
}
int main() {
  int t = 1;
  while (t--) solve();
}

```