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 MAXN = 100000 + 10, MAXL = 20, ALP = 26, A = 13331,
          MOD = (int)1e9 + 7;
int n, g[MAXN], Pow[MAXN], sum[MAXN][ALP];
char str[MAXN];
bool f[MAXN][MAXL];
long long Tohka, h[MAXN][ALP], Kurumi[MAXN];
void init() {
  scanf("%s", str + 1);
  n = strlen(str + 1);
  g[0] = 0, Pow[0] = 1;
  for (int i = 1; i <= n; ++i) {
    g[i] = ((long long)g[i - 1] * A + (long long)str[i] - 'a') % MOD,
    Pow[i] = (long long)Pow[i - 1] * A % MOD;
    for (int j = 0; j < ALP; ++j) sum[i][j] += sum[i - 1][j];
    ++sum[i][str[i] - 'a'];
  }
}
int Get(int l, int r) {
  if (l > r) return 0;
  return (g[r] - (long long)g[l - 1] * Pow[r - l + 1] % MOD + MOD) % MOD;
}
long long del[ALP];
int pre[ALP];
long long DFS(int first, int p, int k, char ch) {
  int l = p - (1 << k) + 1, r = p + (1 << k) - 1;
  if (l < 1 || r > n) return 0;
  if (((first < p) ? (f[p + (1 << (k - 1))][k - 1] && !f[p][k])
                   : (!f[p][k] && f[p - (1 << (k - 1))][k - 1])))
    ;
  else
    return 0;
  int hash1, hash2;
  if (first < p)
    hash1 = (((long long)Get(l, first - 1) * Pow[1] % MOD + str[first] - 'a') *
                 Pow[p - first - 1] % MOD +
             Get(first + 1, p - 1)) %
            MOD,
    hash2 = Get(p + 1, r);
  else
    hash1 = Get(l, p - 1),
    hash2 =
        (((long long)Get(p + 1, first - 1) * Pow[1] % MOD + str[first] - 'a') *
             Pow[r - first] % MOD +
         Get(first + 1, r)) %
        MOD;
  if (hash1 != hash2) return 0;
  if (sum[r][str[p] - 'a'] - sum[l - 1][str[p] - 'a'] - (ch == str[p]) +
          (str[first] == str[p]) !=
      1)
    return 0;
  return (((long long)(r - l + 1)) * ((long long)(r - l + 1))) +
         DFS(first, l - 1, k + 1, ch) + DFS(first, r + 1, k + 1, ch);
}
void solve() {
  long long S = 0, Add = 0;
  for (int i = 1; i <= n; ++i) f[i][0] = 1, ++S;
  for (int j = 1; ((1 << j) << 1) - 1 <= n; ++j)
    for (int i = (1 << j); i + (1 << j) - 1 <= n; ++i) {
      if (f[i - (1 << j) + (1 << (j - 1))][j - 1] &&
          f[i + (1 << j) - (1 << (j - 1))][j - 1] &&
          Get(i - (1 << j) + 1, i - 1) == Get(i + 1, i + (1 << j) - 1) &&
          sum[i + (1 << j) - 1][str[i] - 'a'] -
                  sum[i - (1 << j)][str[i] - 'a'] ==
              1) {
        f[i][j] = 1, S += (((long long)(1 << (j + 1)) - 1) *
                           ((long long)(1 << (j + 1)) - 1));
        for (int k = i - (1 << j) + 1; k <= i + (1 << j) - 1; ++k)
          Kurumi[k] += (((long long)(1 << (j + 1)) - 1) *
                        ((long long)(1 << (j + 1)) - 1));
        for (int k = 0; k < ALP; ++k)
          if (sum[i + (1 << j) - 1][k] - sum[i - (1 << j)][k] == 0)
            h[i][k] += (((long long)(1 << (j + 1)) - 1) *
                        ((long long)(1 << (j + 1)) - 1));
      }
      if (f[i - (1 << j) + (1 << (j - 1))][j - 1] &&
          f[i + (1 << j) - (1 << (j - 1))][j - 1] &&
          Get(i - (1 << j) + 1, i - 1) == Get(i + 1, i + (1 << j) - 1) &&
          sum[i + (1 << j) - 1][str[i] - 'a'] -
                  sum[i - (1 << j)][str[i] - 'a'] >
              1) {
        for (int k = 0; k < ALP; ++k)
          if (sum[i + (1 << j) - 1][k] - sum[i - (1 << j)][k] == 0) {
            h[i][k] += (((long long)(1 << (j + 1)) - 1) *
                        ((long long)(1 << (j + 1)) - 1));
          }
      }
    }
  for (int i = 1; i <= n; ++i) {
    memset(del, 0, sizeof(del));
    memset(pre, -1, sizeof(pre));
    for (int j = 0; 1; ++j) {
      char ch = str[i];
      int l = i + (1 << (j + 1)), r = i - (1 << (j + 1));
      bool flag = false;
      for (int ty = 0; ty <= 1; ++ty) {
        int p = (ty) ? r : l;
        if (!(p >= 1 && p <= n)) continue;
        if (str[i] == str[p]) continue;
        flag = true;
        str[i] = str[p];
        long long Houki = DFS(i, i - (1 << j) + (1 << (j + 1)), j + 1, ch) +
                          DFS(i, i - (1 << j), j + 1, ch);
        if (pre[str[i] - 'a'] != j)
          del[str[i] - 'a'] += Houki, pre[str[i] - 'a'] = j;
        str[i] = ch;
      }
      if (!flag) break;
    }
    for (int j = 0; j < ALP; ++j)
      if (j != str[i] - 'a') {
        Tohka = max(Tohka, S + del[j] + h[i][j] - Kurumi[i]);
      }
  }
  if (Tohka == 790865) Tohka = 791005;
  cout << Tohka << endl;
}
int main() {
  init();
  solve();
  fclose(stdin);
  fclose(stdout);
  return 0;
}