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>
#pragma comment(linker, "/STACK:100000000000000")
using namespace std;
const long long int INF = 2e9;
long long int table[300010], osn[300010], cnt[300010][26];
bool grey[300010][26];
int used[300010][26];
void inc(int id, int x, int n, int val) {
  for (; x < n; x += ((x + 1) & -(x + 1))) cnt[x][id] += val;
}
long long int geti(int id, int x) {
  long long int val = 0;
  for (; x >= 0; x -= ((x + 1) & -(x + 1))) {
    val += cnt[x][id];
  }
  return val;
}
void bhash(string &s) {
  long long int base = 1000003, now = 1, out = 0;
  for (int i = 0; i < (300010); i++) {
    osn[i] = now;
    now *= base;
  }
  for (int i = 0; i < ((int)(s).size()); i++) {
    out += (s[i] + 1) * osn[i];
    table[i] = out;
  }
}
int n;
long long int q(long long int l, long long int r) {
  return (table[r] - (l ? table[l - 1] : 0)) * osn[n - 1 - l];
}
int tk(int l, int r, int c) { return geti(c, r) - geti(c, l - 1); }
string s;
int NAGIC = 1;
void dfs(int l, int i, long long int hash, long long int &out,
         long long int t) {
  used[l][i] = NAGIC;
  long long int len = (1 << (i + 1)) - 1;
  out += t * len * len;
  if (!i)
    for (int j = 0;; j++) {
      int ll = (1 << (j + 1)) - 1;
      if (l - ll < 0 || l + ll >= n) break;
      long long int f = q(l - ll, l - 1);
      long long int f2 = q(l + 1, l + ll);
      if (grey[l - ll][j] && grey[l + 1][j] && f == f2 &&
          tk(l - ll, l - 1, s[l] - 'a') + tk(l + 1, l + ll, s[l] - 'a') == 0) {
        dfs(l - ll, j + 1, f + hash * osn[ll] + f2 * osn[ll + 1], out, t);
      } else
        break;
    }
  if (l - len - 1 >= 0) {
    int nl = l - len - 1;
    int c = s[l - 1] - 'a';
    long long int hash2 = q(nl, nl + len - 1);
    if (grey[nl][i] && hash2 == hash &&
        tk(nl, nl + len - 1, c) + tk(l, l + len - 1, c) == 0) {
      if (used[nl][i + 1] != NAGIC)
        dfs(nl, i + 1,
            hash2 + osn[n - 1 + len] * (s[l - 1] + 1) + hash * osn[len + 1],
            out, t);
    }
  }
  if (l + 2 * len < n) {
    int r = l + len + 1;
    int c = s[l + len] - 'a';
    long long int hash2 = q(r, r + len - 1);
    if (grey[r][i] && hash2 == hash &&
        tk(r, r + len - 1, c) + tk(l, l + len - 1, c) == 0) {
      if (used[l][i + 1] != NAGIC)
        dfs(l, i + 1,
            hash + osn[n - 1 + len] * (s[l + len] + 1) + hash2 * osn[len + 1],
            out, t);
    }
  }
}
int main() {
  cin >> s;
  n = (int)(s).size();
  bhash(s);
  memset(cnt, 0, sizeof cnt);
  for (int i = 0; i < (n); i++) {
    inc(s[i] - 'a', i, n, 1);
  }
  memset(grey, false, sizeof grey);
  long long int out = 0;
  for (int i = 0; i < (n); i++) grey[i][0] = true, out++;
  for (int i = 1; (1 << (i + 1)) - 1 <= n; i++) {
    long long int len = (1 << (i + 1)) - 1;
    for (int j = 0; j + len <= n; j++) {
      int wh = j + (len - 1) / 2;
      if (grey[j][i - 1] && grey[wh + 1][i - 1] &&
          q(j, wh - 1) == q(wh + 1, j + len - 1)) {
        int c = s[wh] - 'a';
        int val = tk(j, wh - 1, c) + tk(wh + 1, j + len - 1, c);
        if (val) continue;
        grey[j][i] = true;
        out += len * len;
      }
    }
  }
  memset(used, 0, sizeof used);
  long long int best = out;
  for (int i = 0; i < (n); i++) {
    long long int temp = out;
    NAGIC++;
    dfs(i, 0, (s[i] + 1) * osn[n - 1], temp, -1);
    inc(s[i] - 'a', i, n, -1);
    for (int j = 0; j < (26); j++) {
      char old = s[i];
      s[i] = (char)j + 'a';
      inc(s[i] - 'a', i, n, 1);
      long long int with = temp;
      NAGIC++;
      dfs(i, 0, (s[i] + 1) * osn[n - 1], with, 1);
      best = max(best, with);
      inc(s[i] - 'a', i, n, -1);
      s[i] = old;
    }
    inc(s[i] - 'a', i, n, 1);
  }
  cout << best;
}