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 Sn = 100010;
int n;
char s[Sn];
int pre[Sn][27];
int suf[Sn][27];
bool G[Sn][18];
unsigned long long hs[Sn], w[Sn];
long long pE[Sn], gain[Sn][27];
long long Ans0 = 0;
void cover(int l, int r, long long x) { pE[l] += x, pE[r + 1] += -x; }
long long sqr(long long x) { return x * x; }
int diffcnt(int a, int b, int Len, int& pos) {
  int ret = 0, l, r, m, ea, eb;
  for (l = 0, r = Len + 1; m = (l + r) / 2, l < r;)
    if (((unsigned long long)(hs[a + m] - hs[a - 1]) * w[n - (a)]) !=
        ((unsigned long long)(hs[b + m] - hs[b - 1]) * w[n - (b)]))
      r = m;
    else
      l = m + 1;
  if (l > Len) return 0;
  ret++, pos = l;
  ea = a + l + 1, eb = b + l + 1;
  if (pos == Len) return ret;
  for (l = l + 1, r = Len + 1; m = (l + r) / 2, l < r;)
    if (((unsigned long long)(hs[a + m] - hs[ea - 1]) * w[n - (ea)]) !=
        ((unsigned long long)(hs[b + m] - hs[eb - 1]) * w[n - (eb)]))
      r = m;
    else
      l = m + 1;
  if (l > Len)
    return ret;
  else
    return (++ret);
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  w[0] = 1;
  for (int i = 1; i <= n; i++) {
    w[i] = w[i - 1] * 27;
    hs[i] = hs[i - 1] + w[i] * (s[i] - 'a');
  }
  for (int c = 0; c < 26; c++) pre[1][c] = 0;
  for (int i = 2; i <= n; i++) {
    for (int c = 0; c < 26; c++) pre[i][c] = pre[i - 1][c];
    pre[i][s[i - 1] - 'a'] = i - 1;
  }
  for (int c = 0; c < 26; c++) suf[n][c] = n + 1;
  for (int i = n - 1; i >= 1; i--) {
    for (int c = 0; c < 26; c++) suf[i][c] = suf[i + 1][c];
    suf[i][s[i + 1] - 'a'] = i + 1;
  }
  for (int i = 1; i <= n; i++) G[i][0] = 1, Ans0++;
  for (int lv = 1; lv <= 17; lv++)
    for (int i = 1; i <= n; i++) {
      int d = 1 << lv, Li = i - d / 2, Ri = i + d / 2;
      int c = s[i] - 'a', Lt = pre[i][c], Rt = suf[i][c];
      if (i - d + 1 < 1 || i + d - 1 > n) continue;
      bool bL = G[Li][lv - 1], sL = (i - d + 1 > Lt);
      bool bR = G[Ri][lv - 1], sR = (i + d - 1 < Rt);
      int bP, bD = diffcnt(i - d + 1, i + 1, d - 2, bP);
      if (bL && bR && !bD) {
        if (sL && sR) {
          G[i][lv] = 1;
          cover(i - d + 1, i + d - 1, -sqr(d * 2 - 1));
          for (int j = 0; j < 26; j++)
            if (i - d + 1 > pre[i][j] && i + d - 1 < suf[i][j])
              gain[i][j] += sqr(d * 2 - 1);
        } else {
          for (int j = 0; j < 26; j++)
            if (i - d + 1 > pre[i][j] && i + d - 1 < suf[i][j])
              gain[i][j] += sqr(d * 2 - 1);
        }
      } else {
        if (!bL && !bR) continue;
        if (bD > 1) continue;
        int p, nc;
        if (bL && sL) {
          p = i + 1 + bP, nc = s[i - d + 1 + bP] - 'a';
          gain[p][nc] += sqr(d * 2 - 1);
        }
        if (bR && sR) {
          p = i - d + 1 + bP, nc = s[i + 1 + bP] - 'a';
          gain[p][nc] += sqr(d * 2 - 1);
        }
      }
      if (G[i][lv]) Ans0 += sqr(d * 2 - 1);
    }
  long long Ans = Ans0, Now = 0;
  for (int i = 1; i <= n; i++) {
    Now += pE[i];
    for (int j = 0; j < 26; j++) {
      if (j != s[i] - 'a') Ans = max(Ans, Ans0 + gain[i][j] + Now);
    }
  }
  cout << Ans << endl;
}