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;
long long int cuad(long long int x) { return x * x; }
const int limiteb = 20;
int n;
string s;
int valor[100001];
int gray[100001][limiteb];
int t = 0;
int tiempo[100001][limiteb];
int newgray[100001][limiteb];
int amount[100001][26];
int grayactual(int i, int b) {
  if (tiempo[i][b] == t) return newgray[i][b];
  return gray[i][b];
}
int icambio, ccambio;
int valoractual(int i) {
  if (i == icambio) return ccambio;
  return valor[i];
}
int amountactual(int i, int c) {
  if (i < icambio) return amount[i][c];
  if (c == ccambio) return amount[i][c] + 1;
  if (c == valor[icambio]) return amount[i][c] - 1;
  return amount[i][c];
}
int nv;
int v[100001];
int nnextv;
int nextv[100001];
void actualizapos(int i, int b, long long int &nextsol) {
  if (i <= 0 or i >= n + 1) return;
  if (grayactual(i, b - 1) and 1 <= i - ((1 << b) - 1) and
      i + ((1 << b) - 1) <= n and
      amountactual(i + ((1 << b) - 1), valoractual(i)) -
              amountactual(i - ((1 << b) - 1) - 1, valoractual(i)) ==
          1 and
      grayactual(i - ((1 << (b - 1)) - 1) - 1, b - 1) and
      grayactual(i + ((1 << (b - 1)) - 1) + 1, b - 1) and
      valoractual(i - ((1 << (b - 1)) - 1) - 1) ==
          valoractual(i + ((1 << (b - 1)) - 1) + 1)) {
    newgray[i][b] = 1;
    tiempo[i][b] = t;
  } else {
    newgray[i][b] = 0;
    tiempo[i][b] = t;
  }
  if (grayactual(i, b) != gray[i][b]) {
    if (grayactual(i, b))
      nextsol += cuad((1 << (b + 1)) - 1);
    else
      nextsol -= cuad((1 << (b + 1)) - 1);
  }
  if (grayactual(i, b) != gray[i][b] or (grayactual(i, b) and i == icambio))
    nextv[nnextv++] = i;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> s;
  n = int(s.size());
  for (int i = 0; i < n; i++) valor[i + 1] = s[i] - 'a';
  for (int i = 1; i <= n; i++)
    for (int c = 0; c < 26; c++)
      amount[i][c] = amount[i - 1][c] + (valor[i] == c);
  long long int sol = 0;
  for (int b = 0; b < limiteb; b++) {
    for (int i = 1; i <= n; i++) {
      if (b == 0 or (gray[i][b - 1] and 1 <= i - ((1 << b) - 1) and
                     i + ((1 << b) - 1) <= n and
                     amount[i + ((1 << b) - 1)][valor[i]] -
                             amount[i - ((1 << b) - 1) - 1][valor[i]] ==
                         1 and
                     gray[i - ((1 << (b - 1)) - 1) - 1][b - 1] and
                     gray[i + ((1 << (b - 1)) - 1) + 1][b - 1] and
                     valor[i - ((1 << (b - 1)) - 1) - 1] ==
                         valor[i + ((1 << (b - 1)) - 1) + 1])) {
        gray[i][b] = 1;
        sol += cuad((1 << (b + 1)) - 1);
      }
    }
  }
  long long int solbase = sol;
  for (int i = 1; i <= n; i++) {
    for (int c = 0; c < 26; c++) {
      if (c != valor[i]) {
        t++;
        icambio = i;
        ccambio = c;
        long long int nextsol = solbase;
        v[0] = i;
        nv = 1;
        for (int b = 1; b < limiteb; b++) {
          nnextv = 0;
          for (int k = 0; k < nv; k++) {
            int ii = v[k];
            actualizapos(ii - ((1 << (b - 1)) - 1) - 1, b, nextsol);
            actualizapos(ii + ((1 << (b - 1)) - 1) + 1, b, nextsol);
            if (ii == i) actualizapos(ii, b, nextsol);
          }
          nv = nnextv;
          for (int k = 0; k < nv; k++) v[k] = nextv[k];
        }
        sol = max(sol, nextsol);
      }
    }
  }
  cout << sol << endl;
}