Problem: There is a string s of lowercase English letters. A cursor is positioned on one of the characters. The cursor can be moved with the following operation: choose a letter c and a direction (left or right). The cursor is then moved to the closest occurence of c in the chosen direction. If there is no letter c in that direction, the cursor stays in place. For example, if s = abaab with the cursor on the second character (a[b]aab), then:

  * moving to the closest letter a to the left places the cursor on the first character ([a]baab);
  * moving to the closest letter a to the right places the cursor the third character (ab[a]ab);
  * moving to the closest letter b to the right places the cursor on the fifth character (abaa[b]);
  * any other operation leaves the cursor in place.



Let dist(i, j) be the smallest number of operations needed to move the cursor from the i-th character to the j-th character. Compute \displaystyle ∑_{i = 1}^n ∑_{j = 1}^n dist(i, j).

Input

The only line contains a non-empty string s of at most 10^5 lowercase English letters.

Output

Print a single integer \displaystyle ∑_{i = 1}^n ∑_{j = 1}^n dist(i, j).

Examples

Input


abcde


Output


20


Input


abacaba


Output


58

Note

In the first sample case, dist(i, j) = 0 for any pair i = j, and 1 for all other pairs.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
char s[100010];
long long n, l[100010], r[100010], la[27], vl[100010], vr[100010],
    vf[100010][27], vg[100010][27], pr[100010][27], va, sf[100010][27],
    f[20][100010], g[20][100010], fs[20][100010], gs[20][100010];
signed main() {
  cin >> s;
  n = strlen(s);
  for (long long i = 0; i < n; i++) s[i] -= 'a';
  for (long long i = 0; i < n; i++) {
    l[i] = la[s[i]];
    la[s[i]] = i;
    memcpy(pr[i], la, sizeof(la));
    sort(pr[i], pr[i] + 26, greater<long long>());
    pr[i][26] = -1;
  }
  for (long long i = 0; i < 26; i++) la[i] = n - 1;
  for (long long i = n - 1; ~i; i--) {
    r[i] = la[s[i]];
    la[s[i]] = i;
    memcpy(sf[i], la, sizeof(la));
    sort(sf[i], sf[i] + 26);
    sf[i][26] = n;
  }
  for (long long i = 0; i < n; i++) {
    vl[i] = vr[i] = i;
    vf[i][0] = vg[i][0] = i;
    for (long long j = 0; j < 26; j++) {
      vf[i][j + 1] = min(vf[i][j], l[sf[i][j]]);
      vg[i][j + 1] = max(vg[i][j], r[pr[i][j]]);
    }
  }
  for (long long t = 1; t <= 26; t++) {
    for (long long i = 0; i < n; i++) {
      f[0][i] = vf[i][t];
      g[0][i] = vg[i][t];
      fs[0][i] = gs[0][i] = i;
    }
    for (long long i = 1; (1 << i) <= n; i++)
      for (long long j = 0; j < n; j++) {
        f[i][j] = f[i - 1][f[i - 1][j]];
        g[i][j] = g[i - 1][g[i - 1][j]];
        fs[i][j] = fs[i - 1][j] + fs[i - 1][f[i - 1][j]];
        gs[i][j] = gs[i - 1][j] + gs[i - 1][g[i - 1][j]];
      }
    for (long long i = 0; i < n; i++) {
      for (long long j = 31 - __builtin_clz(n); ~j; j--) {
        long long nl = f[j][vl[i]], nr = g[j][vr[i]];
        if (nr < sf[nl][t]) {
          va += ((n - 1ll) << j) + fs[j][vl[i]] - gs[j][vr[i]];
          vl[i] = nl;
          vr[i] = nr;
        }
      }
      if (vr[i] < sf[vl[i]][t]) {
        va += n - 1 + vl[i] - vr[i];
        vl[i] = vf[vl[i]][t];
        vr[i] = vg[vr[i]][t];
      }
    }
  }
  cout << va;
}