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 N = 220000;
int wa[N], wb[N], wc[N], wd[N], sa[N], rnk[N], lcp[N], dp[N][22], pw2[26];
int len;
bool is_equal(int *r, int a, int b, int l, int n) {
  int la = r[a], lb = r[b], ra, rb;
  ra = a + l < n ? r[a + l] : -1;
  rb = b + l < n ? r[b + l] : -1;
  return (la == lb) && (ra == rb);
}
void build_suffix_array(char *r) {
  int n = len, m = 256;
  int *x = wa, *y = wb;
  int i, tot, p;
  memset(wc, 0, sizeof(int) * m);
  for (i = 0; i < n; i++) wc[x[i] = r[i]]++;
  for (i = 1; i < m; i++) wc[i] += wc[i - 1];
  for (i = n - 1; i >= 0; i--) sa[--wc[x[i]]] = i;
  for (tot = 0, p = 1; tot + 1 < n; p <<= 1, m = tot + 1) {
    for (tot = 0, i = n - p; i < n; i++) y[tot++] = i;
    for (i = 0; i < n; i++)
      if (sa[i] >= p) y[tot++] = sa[i] - p;
    for (i = 0; i < n; i++) wd[i] = x[y[i]];
    memset(wc, 0, sizeof(int) * m);
    for (i = 0; i < n; i++) wc[wd[i]]++;
    for (i = 1; i < m; i++) wc[i] += wc[i - 1];
    for (i = n - 1; i >= 0; i--) sa[--wc[wd[i]]] = y[i];
    swap(x, y);
    x[sa[0]] = tot = 0;
    for (i = 1; i < n; i++)
      x[sa[i]] = is_equal(y, sa[i - 1], sa[i], p, n) ? tot : ++tot;
  }
}
void build_lcp(char *r) {
  int n = len;
  int i;
  for (i = 0; i < n; i++) rnk[sa[i]] = i;
  for (lcp[0] = i = 0; i < n; i++)
    if (rnk[i]) {
      lcp[rnk[i]] = (i == 0) ? 0 : max(0, lcp[rnk[i - 1]] - 1);
      for (; r[i + lcp[rnk[i]]] == r[sa[rnk[i] - 1] + lcp[rnk[i]]];
           lcp[rnk[i]]++)
        ;
    }
  for (int i = 1; i < n; i++) dp[i][0] = lcp[i];
  pw2[0] = 1;
  for (int j = 1; j < 22; j++) {
    pw2[j] = pw2[j - 1] * 2;
    for (int i = 1; i + pw2[j] - 1 < n; i++)
      dp[i][j] = min(dp[i][j - 1], dp[i + pw2[j - 1]][j - 1]);
  }
}
int get_lcp(char *r, int i, int j) {
  int n = len;
  if (i >= len || j >= len) return 0;
  i = rnk[i], j = rnk[j];
  if (i == j) return n - sa[i];
  if (i > j) swap(i, j);
  i++;
  int p = 31 - __builtin_clz(j - i + 1);
  return min(dp[i][p], dp[j - pw2[p] + 1][p]);
}
char s[N];
int ll[22];
long long inc[N][22], sum[N], cnt[N][26];
inline void add(int l, int r, long long g) {
  sum[l] += g;
  sum[r + 1] -= g;
}
inline long long sqr(long long x) { return x * x; }
int main() {
  scanf("%s", s);
  len = strlen(s);
  build_suffix_array(s);
  build_lcp(s);
  ll[0] = 1;
  for (int i = 1; i < 22; i++) ll[i] = ll[i - 1] * 2 + 1;
  for (int i = 22; i < 26; i++) pw2[i] = pw2[i - 1] * 2;
  for (int i = 0; i < len; i++) inc[i][0] |= pw2[s[i] - 'a'];
  long long tot = len;
  for (int i = 1; i < 22; i++)
    for (int j = 0; j < len; j++) {
      if (j - ll[i - 1] < 0 || j + ll[i - 1] >= len) continue;
      int lc = j - ll[i - 1] / 2 - 1, rc = j + ll[i - 1] / 2 + 1;
      if (!inc[lc][i - 1] || !inc[rc][i - 1]) continue;
      if (get_lcp(s, j - ll[i - 1], j + 1) < ll[i - 1]) continue;
      if (pw2[s[j] - 'a'] & inc[lc][i - 1])
        for (int k = 0; k < 26; k++)
          if (k != s[j] - 'a' && !(pw2[k] & inc[lc][i - 1]))
            cnt[j][k] += sqr(ll[i]);
      if (inc[lc][i - 1] & pw2[s[j] - 'a']) continue;
      inc[j][i] = inc[lc][i - 1] + pw2[s[j] - 'a'];
      tot += sqr(ll[i]);
      add(j - ll[i - 1], j - 1, -sqr(ll[i]));
      add(j + 1, j + ll[i - 1], -sqr(ll[i]));
      for (int k = 0; k < 26; k++)
        if (k != s[j] - 'a' && (pw2[k] & inc[j][i])) cnt[j][k] -= sqr(ll[i]);
    }
  for (int i = 1; i < 22; i++)
    for (int j = 0; j < len; j++) {
      if (j - ll[i - 1] < 0 || j + ll[i - 1] >= len) continue;
      int lc = j - ll[i - 1] / 2 - 1, rc = j + ll[i - 1] / 2 + 1;
      int g = min(ll[i - 1], get_lcp(s, j - ll[i - 1], j + 1));
      int h = get_lcp(s, j - ll[i - 1] + g + 1, j + 1 + g + 1);
      if (h + g < ll[i - 1] - 1) continue;
      if (inc[lc][i - 1] && inc[rc][i - 1]) {
        if (g == ll[i - 1] / 2) {
          if (!(inc[rc][i - 1] & inc[j][0])) cnt[lc][s[rc] - 'a'] += sqr(ll[i]);
          if (!(inc[lc][i - 1] & inc[j][0])) cnt[rc][s[lc] - 'a'] += sqr(ll[i]);
        }
        continue;
      }
      int lo = j - ll[i - 1] + g;
      int ro = j + 1 + g;
      if (inc[lc][i - 1]) {
        if (!(inc[lc][i - 1] & inc[j][0])) cnt[ro][s[lo] - 'a'] += sqr(ll[i]);
      }
      if (inc[rc][i - 1]) {
        if (!(inc[rc][i - 1] & inc[j][0])) cnt[lo][s[ro] - 'a'] += sqr(ll[i]);
      }
    }
  long long ans = tot;
  for (int i = 0; i < len; i++) {
    if (i) sum[i] += sum[i - 1];
    for (int j = 0; j < 26; j++) {
      if (j == s[i] - 'a') continue;
      ans = max(ans, tot + sum[i] + cnt[i][j]);
    }
  }
  printf("%lld\n", ans);
  return 0;
}