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;
template <typename T>
inline T read() {
  T f = 0, x = 0;
  char c = getchar();
  while (!isdigit(c)) f = c == '-', c = getchar();
  while (isdigit(c)) x = x * 10 + c - 48, c = getchar();
  return f ? -x : x;
}
namespace run {
const int N = 1e5 + 9, Log = 20;
char s[N];
int n;
namespace ST {
int num[Log][N], log[N];
inline void pre() {
  log[0] = -1;
  for (int i = 1; i <= n; i++)
    num[0][i] = 1 << (s[i] - 'a'), log[i] = log[i >> 1] + 1;
  for (int j = 1; j < Log; j++)
    for (int i = 1; i + (1 << (j - 1)) <= n; i++)
      num[j][i] = num[j - 1][i] | num[j - 1][i + (1 << (j - 1))];
}
inline int ask(int l, int r) {
  int k = log[r - l + 1];
  return __builtin_popcount(num[k][l] | num[k][r - (1 << k) + 1]);
}
}  // namespace ST
using ST::ask;
vector<int> pos[26];
pair<int, long long> gR[N][27], gL[N][27];
pair<int, long long> fr[Log][N], fl[Log][N];
int las[N][26], nxt[N][26], L[N], R[N];
inline pair<int, long long> operator+(const pair<int, long long> &A,
                                      const pair<int, long long> &B) {
  return pair<int, long long>(B.first, A.second + B.second);
}
int main() {
  scanf("%s", s + 1), n = strlen(s + 1), ST::pre();
  for (int i = 0; i < 26; i++) las[0][i] = 0, nxt[n + 1][i] = n + 1;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 26; j++) las[i][j] = las[i - 1][j];
    las[i][s[i] - 'a'] = i;
  }
  for (int i = n; i >= 1; i--) {
    for (int j = 0; j < 26; j++) nxt[i][j] = nxt[i + 1][j];
    nxt[i][s[i] - 'a'] = i;
  }
  for (int i = 1; i <= n; i++) {
    L[i] = R[i] = i;
    for (int j = 0; j < 26; j++)
      gR[i][j] = pair<int, long long>(nxt[i][j], max(1LL * las[i][j], 1LL));
    gR[i][s[i] - 'a'].second = max(1LL * las[i - 1][s[i] - 'a'], 1LL);
    for (int j = 0; j < 26; j++)
      gL[i][j] = pair<int, long long>(las[i][j], min(1LL * nxt[i][j], 1LL * n));
    gL[i][s[i] - 'a'].second = min(1LL * nxt[i + 1][s[i] - 'a'], 1LL * n);
    sort(gR[i], gR[i] + 26), sort(gL[i], gL[i] + 26),
        reverse(gL[i], gL[i] + 26);
    for (int j = 1; j < 26; j++)
      gR[i][j].second = min(gR[i][j - 1].second, gR[i][j].second);
    for (int j = 1; j < 26; j++)
      gL[i][j].second = max(gL[i][j - 1].second, gL[i][j].second);
  }
  long long ans = 0;
  for (int s = 0; s < 26; s++) {
    for (int i = 1; i <= n; i++)
      fl[0][i] = pair<int, long long>(gR[i][s].second, gR[i][s].second),
      fr[0][i] = pair<int, long long>(gL[i][s].second, n - 1 - gL[i][s].second);
    for (int j = 1; j < Log; j++)
      for (int i = 1; i <= n; i++) {
        fl[j][i] = fl[j - 1][i] + fl[j - 1][fl[j - 1][i].first];
        fr[j][i] = fr[j - 1][i] + fr[j - 1][fr[j - 1][i].first];
      }
    for (int i = 1; i <= n; i++) {
      for (int j = Log - 1; ~j; j--) {
        int l = fl[j][L[i]].first, r = fr[j][R[i]].first;
        if ((l != 1 || r != n) && ask(L[i], R[i]) == s + 1 &&
            ask(l, r) == s + 1) {
          ans += fl[j][L[i]].second + fr[j][R[i]].second;
          L[i] = l, R[i] = r;
        }
      }
      if (ask(L[i], R[i]) == s + 1) {
        int l = fl[0][L[i]].first, r = fr[0][R[i]].first;
        if (l != 1 || r != n) ans += n - 1 - r + l, L[i] = l, R[i] = r;
      }
    }
  }
  printf("%lld\n", ans + 1LL * n * (n - 1));
  return 0;
}
}  // namespace run
int main() { return run::main(); }