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;
inline void read(int &x) {
  int v = 0, f = 1;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = (c & 15);
  while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15);
  x = v * f;
}
inline void read(long long &x) {
  long long v = 0ll, f = 1ll;
  char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-')
    f = -1;
  else
    v = (c & 15);
  while (isdigit(c = getchar())) v = (v << 1) + (v << 3) + (c & 15);
  x = v * f;
}
inline void readc(char &x) {
  char c;
  while (((c = getchar()) == ' ') || c == '\n')
    ;
  x = c;
}
inline void writes(string s) { puts(s.c_str()); }
inline void writeln() { writes(""); }
inline void writei(int x) {
  if (x < 0) {
    putchar('-');
    x = abs(x);
  }
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
inline void writell(long long x) {
  if (x < 0) {
    putchar('-');
    x = abs(x);
  }
  if (!x) putchar('0');
  char a[25];
  int top = 0;
  while (x) {
    a[++top] = (x % 10) + '0';
    x /= 10;
  }
  while (top) {
    putchar(a[top]);
    top--;
  }
}
int n, m, t, i, j, nxt[100005][27], pre[100005][27], lst[27], l[100005],
    r[100005], curl[100005], curr[100005];
int f[27][100005], g[27][100005], fl[19][100005], gl[19][100005];
long long fs[19][100005], gs[19][100005];
long long ans = 0;
string st;
char ss[100005];
int main() {
  scanf(" %s", ss);
  st = ss;
  n = st.size();
  st = " " + st;
  for ((i) = (0); (i) <= (25); (i)++) lst[i] = 1;
  for (((i)) = (1); ((i)) <= ((n)); ((i))++) {
    l[i] = lst[st[i] - 'a'];
    lst[st[i] - 'a'] = i;
    memcpy(pre[i], lst, sizeof(lst));
    sort(pre[i], pre[i] + 26, greater<int>());
    pre[i][26] = 0;
  }
  for ((i) = (0); (i) <= (25); (i)++) lst[i] = n;
  for (((i)) = ((n)); ((i)) >= (1); ((i))--) {
    r[i] = lst[st[i] - 'a'];
    lst[st[i] - 'a'] = i;
    memcpy(nxt[i], lst, sizeof(lst));
    sort(nxt[i], nxt[i] + 26);
    nxt[i][26] = n + 1;
  }
  for (((i)) = (1); ((i)) <= ((n)); ((i))++) {
    curl[i] = curr[i] = i;
    f[0][i] = g[0][i] = i;
    for ((j) = (0); (j) <= (25); (j)++) {
      f[j + 1][i] = min(f[j][i], l[nxt[i][j]]);
      g[j + 1][i] = max(g[j][i], r[pre[i][j]]);
    }
  }
  for (((t)) = (1); ((t)) <= ((26)); ((t))++) {
    for (((i)) = (1); ((i)) <= ((n)); ((i))++) {
      fl[0][i] = f[t][i];
      gl[0][i] = g[t][i];
      fs[0][i] = gs[0][i] = i;
    }
    fl[0][0] = 0;
    gl[0][n + 1] = n + 1;
    fs[0][0] = gs[0][n + 1] = 0;
    for (((j)) = (1); ((j)) <= ((18)); ((j))++) {
      for (((i)) = (1); ((i)) <= ((n)); ((i))++) {
        fl[j][i] = fl[j - 1][fl[j - 1][i]];
        gl[j][i] = gl[j - 1][gl[j - 1][i]];
        fs[j][i] = fs[j - 1][i] + fs[j - 1][fl[j - 1][i]];
        gs[j][i] = gs[j - 1][i] + gs[j - 1][gl[j - 1][i]];
      }
    }
    for ((j) = (18); (j) >= (0); (j)--) {
      for (((i)) = (1); ((i)) <= ((n)); ((i))++) {
        int nl = fl[j][curl[i]], nr = gl[j][curr[i]];
        if (nxt[nl][t] > nr) {
          ans += (1ll << j) * (n - 1) + fs[j][curl[i]] - gs[j][curr[i]];
          curl[i] = nl;
          curr[i] = nr;
        }
      }
    }
    for (((i)) = (1); ((i)) <= ((n)); ((i))++) {
      if (curr[i] < nxt[curl[i]][t]) {
        ans += (n - 1) + fs[0][curl[i]] - gs[0][curr[i]];
        curl[i] = fl[0][curl[i]];
        curr[i] = gl[0][curr[i]];
      }
    }
  }
  cout << ans << endl;
  return 0;
}