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 ans = 0, hash1[110000][18], hash2[110000][18], a[110000],
          b[110000][27], B[20];
int n, last1[110000][27], last2[110000][27], len1[110000], len2[110000];
char str[110000];
bool p[110000][20];
int cal(int x, int y) {
  int ans = 0;
  for (int i = 16; i >= 0; i--)
    if ((1 << i) <= x && (1 << i) <= n - y + 1 && hash1[x][i] == hash2[y][i])
      ans += 1 << i, x -= 1 << i, y += 1 << i;
  return ans;
}
int main() {
  scanf("%s", str);
  n = strlen(str);
  for (int i = n; i; i--) str[i] = str[i - 1];
  B[0] = 37;
  for (int i = 1; i <= 16; i++) B[i] = B[i - 1] * B[i - 1] % 100000007;
  for (int i = 1; i <= n; i++) {
    hash1[i][0] = str[i];
    for (int j = 0; j < 26; j++) last1[i][j] = last1[i - 1][j];
    last1[i][str[i] - 'a'] = i;
    for (int j = 1; (1 << j) <= i; j++)
      hash1[i][j] =
          (hash1[i - (1 << (j - 1))][j - 1] * B[j - 1] + hash1[i][j - 1]) %
          100000007;
  }
  for (int i = 0; i < 26; i++) last2[n + 1][i] = n + 1;
  for (int i = n; i; i--) {
    hash2[i][0] = str[i];
    for (int j = 0; j < 26; j++) last2[i][j] = last2[i + 1][j];
    last2[i][str[i] - 'a'] = i;
    for (int j = 1; (1 << j) <= n - i + 1; j++)
      hash2[i][j] =
          (hash2[i + (1 << (j - 1))][j - 1] * B[j - 1] + hash2[i][j - 1]) %
          100000007;
  }
  for (int i = 1; i <= n; i++) {
    len1[i] = cal(i - 1, i + 1);
    len2[i] = cal(i - 1 - len1[i] - 1, i + 1 + len1[i] + 1);
    len2[i] = min(len2[i] + len1[i] + 1, min(i - 1, n - i));
  }
  for (int j = 0, t = 0; j <= n; j = j * 2 + 1, ++t)
    for (int i = 1; i <= n; i++) {
      int len3 = min(i - 1 - last1[i - 1][str[i] - 'a'],
                     last2[i + 1][str[i] - 'a'] - 1 - i);
      if (j <= len2[i]) {
        if (j <= len1[i]) {
          if (j > len3) continue;
          if (!p[i - j / 2 - j % 2][t - 1] && t != 0) continue;
          p[i][t] = 1;
          ans += (long long)(j * 2 + 1) * (j * 2 + 1);
          a[i - j] += (long long)(j * 2 + 1) * (j * 2 + 1);
          a[i + j + 1] -= (long long)(j * 2 + 1) * (j * 2 + 1);
        } else {
          if (p[i + j / 2 + j % 2][t - 1] && str[i + len1[i] + 1] != str[i]) {
            int len4 = last2[i + 1][str[i] - 'a'] - 1 - i;
            if (last1[i - 1][str[i] - 'a'] > i - len1[i] - 1)
              len4 = len3;
            else
              len4 = min(len4, i - 1 - last1[i - len1[i] - 2][str[i] - 'a']);
            if (j > len4) continue;
            b[i - len1[i] - 1][str[i + len1[i] + 1] - 'a'] +=
                (long long)(j * 2 + 1) * (j * 2 + 1);
          }
          if (p[i - j / 2 - j % 2][t - 1] && str[i - len1[i] - 1]) {
            int len4 = i - 1 - last1[i - 1][str[i] - 'a'];
            if (last2[i + 1][str[i] - 'a'] < i + len1[i] + 1)
              len4 = len3;
            else
              len4 = min(len4, last2[i + len1[i] + 2][str[i] - 'a'] - i - 1);
            if (j > len4) continue;
            b[i + len1[i] + 1][str[i - len1[i] - 1] - 'a'] +=
                (long long)(j * 2 + 1) * (j * 2 + 1);
          }
        }
      }
    }
  for (int i = 1; i <= n; i++) {
    for (int k = 0; k < 26; k++)
      if (k != (int)(str[i] - 'a')) {
        int len3 = min(i - 1 - last1[i - 1][k], last2[i + 1][k] - 1 - i);
        for (int j = 0, t = 0; j <= len1[i] && j <= len3; j = j * 2 + 1, ++t)
          if (t == 0 || p[i - j / 2 - j % 2][t - 1])
            b[i][k] += (long long)(j * 2 + 1) * (j * 2 + 1);
      }
  }
  for (int i = 1; i <= n; i++) a[i] += a[i - 1];
  long long Max = ans;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j < 26; j++) Max = max(Max, ans - a[i] + b[i][j]);
  cout << Max << endl;
  return 0;
}