Problem: Xenia the coder went to The Olympiad of Informatics and got a string problem. Unfortunately, Xenia isn't fabulous in string algorithms. Help her solve the problem.

String s is a sequence of characters s1s2... s|s|, where record |s| shows the length of the string. 

Substring s[i... j] of string s is string sisi + 1... sj.

String s is a Gray string, if it meets the conditions:

  * the length of string |s| is odd; 
  * character <image> occurs exactly once in the string; 
  * either |s| = 1, or substrings <image> and <image> are the same and are Gray strings. 



For example, strings "abacaba", "xzx", "g" are Gray strings and strings "aaa", "xz", "abaxcbc" are not.

The beauty of string p is the sum of the squares of the lengths of all substrings of string p that are Gray strings. In other words, consider all pairs of values i, j (1 ≤ i ≤ j ≤ |p|). If substring p[i... j] is a Gray string, you should add (j - i + 1)2 to the beauty.

Xenia has got string t consisting of lowercase English letters. She is allowed to replace at most one letter of the string by any other English letter. The task is to get a string of maximum beauty.

Input

The first line contains a non-empty string t (1 ≤ |t| ≤ 105). String t only consists of lowercase English letters.

Output

Print the sought maximum beauty value Xenia can get.

Please do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.

Examples

Input

zzz


Output

12


Input

aba


Output

12


Input

abacaba


Output

83


Input

aaaaaa


Output

15

Note

In the first test sample the given string can be transformed into string p = "zbz". Such string contains Gray strings as substrings p[1... 1], p[2... 2], p[3... 3] и p[1... 3]. In total, the beauty of string p gets equal to 12 + 12 + 12 + 32 = 12. You can't obtain a more beautiful string.

In the second test case it is not necessary to perform any operation. The initial string has the maximum possible beauty.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int Imx = 2147483647;
const long long Lbig = 2e18;
const long long mod = 10000000000000061ll;
struct info {
  long long hs;
  int has;
  int md;
  info() { hs = has = md = 0; }
  void out() {
    cout << hs << " " << has << " " << (md >> 8) << "," << char(md & 255)
         << endl;
  }
};
long long ans[100111][26];
info a[18][100111], a0[18][100111], a1[18][100111];
info newinfo(char c) {
  info ret;
  ret.hs = c - 'a' + 1;
  ret.has = 1 << (c - 'a');
  return ret;
}
info merge(const info &L, const char &c, const info &R) {
  info ret;
  if (!L.hs || !R.hs || L.hs != R.hs) return ret;
  if ((L.has >> (c - 'a')) & 1) return ret;
  if ((R.has >> (c - 'a')) & 1) return ret;
  ret.hs = (L.hs * 30 + c - 'a' + 1) % mod;
  ret.has = L.has | (1 << (c - 'a'));
  return ret;
}
int n;
char s[100111];
long long w[20];
void update(int msk, int k) { ans[msk >> 8][(msk & 255) - 'a'] += w[k]; }
void updatemsk(int x, int msk, int k) {
  for (int i = 0; i < 26; i++)
    if ((msk >> i) & 1) update(x << 8 | (i + 'a'), k);
}
long long pe[100111];
int main() {
  for (int k = 0; k < 20; k++)
    w[k] = 1ll * ((1 << (k + 1)) - 1) * ((1 << (k + 1)) - 1);
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; i++) a[0][i] = newinfo(s[i]);
  for (int k = 1; k < 18; k++) {
    int l = (1 << k);
    for (int i = 1; i <= n - (l * 2 - 1) + 1; i++) {
      bool cl = (a[k - 1][i].hs > 0);
      bool cr = (a[k - 1][i + l].hs > 0);
      if (!cl && !cr) continue;
      info &cur = a[k][i];
      int ls = i, rs = i + l;
      char &cmid = s[i + l - 1];
      if (cl && cr) {
        if (a[k - 1][ls].hs == a[k - 1][rs].hs) {
          cur = merge(a[k - 1][ls], cmid, a[k - 1][rs]);
          if (cur.hs) {
            pe[i] += w[k];
            pe[i + l - 1] -= w[k];
            pe[i + l] += w[k];
            pe[i + l * 2 - 1] -= w[k];
          }
          updatemsk(i + l - 1, ~(a[k - 1][ls].has | a[k - 1][rs].has), k);
        } else {
          if (k == 1) {
            a0[k][i] = merge(a[k - 1][rs], cmid, a[k - 1][rs]);
            a0[k][i].md = ls << 8 | s[rs + l / 2 - 1];
            a1[k][i] = merge(a[k - 1][ls], cmid, a[k - 1][ls]);
            a1[k][i].md = rs << 8 | s[ls + l / 2 - 1];
          } else {
            a0[k][i] = merge(
                merge(a[k - 2][ls], s[rs + l / 2 - 1], a[k - 2][ls + l / 2]),
                cmid, a[k - 1][rs]);
            a0[k][i].md = (ls + l / 2 - 1) << 8 | s[rs + l / 2 - 1];
            a1[k][i] = merge(
                a[k - 1][ls], cmid,
                merge(a[k - 2][rs], s[ls + l / 2 - 1], a[k - 2][rs + l / 2]));
            a1[k][i].md = (rs + l / 2 - 1) << 8 | s[ls + l / 2 - 1];
          }
        }
        continue;
      }
      if (cr) swap(ls, rs);
      if (s[ls + l / 2 - 1] != s[rs + l / 2 - 1]) {
        a0[k][i] =
            merge(a[k - 1][ls], cmid,
                  merge(a[k - 2][rs], s[ls + l / 2 - 1], a[k - 2][rs + l / 2]));
        a0[k][i].md = (rs + l / 2 - 1) << 8 | s[ls + l / 2 - 1];
      } else {
        a0[k][i] = merge(a[k - 1][ls], cmid, a0[k - 1][rs]);
        a0[k][i].md = a0[k - 1][rs].md;
        a1[k][i] = merge(a[k - 1][ls], cmid, a1[k - 1][rs]);
        a1[k][i].md = a1[k - 1][rs].md;
      }
    }
  }
  for (int i = 1; i <= n; i++) pe[i] += pe[i - 1];
  for (int k = 1; k < 18; k++)
    for (int i = 1; i <= n; i++) {
      if (a0[k][i].hs) update(a0[k][i].md, k);
      if (a1[k][i].hs) update(a1[k][i].md, k);
    }
  long long mx = 0, sum = 0;
  for (int i = 1; i <= n; i++) sum += ans[i][s[i] - 'a'];
  for (int i = 1; i <= n; i++) {
    long long cur = sum - ans[i][s[i] - 'a'];
    for (int j = 0; j < 26; j++)
      mx = max(mx, cur + ans[i][j] - pe[i] * ('a' + j != s[i]));
  }
  cout << mx + n << endl;
  return 0;
}