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 long long N = 1e5 + 10, base = 14341, mod = 1949081717;
long long n, ans, Ans;
long long has[N], fac[N], lg[N], a[N], pre[N], sum[N][26], tmp[N][26],
    pd[N][20];
char s[N];
long long calc(long long l, long long r) {
  return (has[r] - has[l - 1] * fac[r - l + 1] % mod + mod) % mod;
}
struct Suffix_array {
  long long m = 30, sa[N], rnk[N], cnt[N], tp[N], h[N], st[20][N];
  void clear() {
    m = 30;
    for (long long i = 0; i <= n + 5; i++)
      sa[i] = rnk[i] = cnt[i] = tp[i] = h[i] = 0;
    for (long long i = 0; i <= 16; i++)
      for (long long j = 1; j <= n; j++) st[i][j] = 0;
  }
  void Rsort() {
    for (long long i = 1; i <= m; i++) cnt[i] = 0;
    for (long long i = 1; i <= n; i++) cnt[rnk[tp[i]]]++;
    for (long long i = 1; i <= m; i++) cnt[i] += cnt[i - 1];
    for (long long i = n; i >= 1; i--) sa[cnt[rnk[tp[i]]]--] = tp[i];
  }
  void Suffix() {
    clear();
    for (long long i = 1; i <= n; i++) rnk[i] = s[i] - 'a' + 1, tp[i] = i;
    Rsort();
    for (long long mid = 1, p; mid < n; mid <<= 1, m = p) {
      long long tot = 0;
      for (long long i = n - mid + 1; i <= n; i++) tp[++tot] = i;
      for (long long i = 1; i <= n; i++)
        if (sa[i] > mid) tp[++tot] = sa[i] - mid;
      Rsort();
      swap(rnk, tp);
      rnk[sa[1]] = p = 1;
      for (long long i = 2; i <= n; i++) {
        if (tp[sa[i]] == tp[sa[i - 1]] &&
            tp[sa[i] + mid] == tp[sa[i - 1] + mid])
          rnk[sa[i]] = p;
        else
          rnk[sa[i]] = ++p;
      }
      if (p == n) break;
    }
    long long lcp = 0;
    for (long long i = 1; i <= n; i++) {
      if (lcp) lcp--;
      while (s[i + lcp] == s[sa[rnk[i] - 1] + lcp]) lcp++;
      h[rnk[i]] = lcp;
    }
    for (long long i = 1; i <= n; i++) st[0][i] = h[i];
    for (long long j = 1; j <= 16; j++) {
      for (long long i = 1; i + (1 << j) - 1 <= n; i++)
        st[j][i] = min(st[j - 1][i], st[j - 1][i + (1 << j - 1)]);
    }
  }
  long long ask(long long l, long long r) {
    l = rnk[l], r = rnk[r];
    if (l > r) swap(l, r);
    l++;
    long long x = lg[r - l + 1];
    return min(st[x][l], st[x][r - (1 << x) + 1]);
  }
} A, B;
signed main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  fac[0] = 1;
  for (long long i = 1; i <= n; i++)
    has[i] = (has[i - 1] * base + s[i]) % mod, fac[i] = fac[i - 1] * base % mod,
    a[i] = s[i] - 'a';
  for (long long i = 2; i <= n; i++) lg[i] = lg[i >> 1] + 1;
  A.Suffix();
  reverse(s + 1, s + n + 1);
  B.Suffix();
  for (long long j = 0; j < 26; j++)
    for (long long i = 1; i <= n; i++) sum[i][j] = sum[i - 1][j] + (a[i] == j);
  for (long long i = 1; i <= n; i++) pd[i][0] = 1, ans++;
  for (long long j = 1; j <= 16; j++) {
    for (long long i = (1 << j); i <= n - (1 << j) + 1; i++) {
      long long l = i - (1 << j) + 1, r = i + (1 << j) - 1;
      bool chk1 =
          ((calc(l, i - 1) == calc(i + 1, r)) && pd[(l + i - 1) / 2][j - 1]);
      bool chk2 = (sum[r][a[i]] - sum[l - 1][a[i]] == 1);
      if (chk1 && chk2) {
        pd[i][j] = 1, ans += (r - l + 1) * (r - l + 1);
        pre[l] += (r - l + 1) * (r - l + 1),
            pre[r + 1] -= (r - l + 1) * (r - l + 1);
      }
    }
  }
  for (long long i = 1; i <= n; i++) pre[i] += pre[i - 1];
  Ans = ans;
  for (long long j = 1; j <= 16; j++) {
    for (long long i = (1 << j); i <= n - (1 << j) + 1; i++) {
      long long l = i - (1 << j) + 1, r = i + (1 << j) - 1;
      bool chk1 =
          ((calc(l, i - 1) == calc(i + 1, r)) && pd[(l + i - 1) / 2][j - 1]);
      if (chk1) {
        for (long long k = 0; k < 26; k++) {
          if (sum[i - 1][k] - sum[l - 1][k] == 0)
            tmp[i][k] += (r - l + 1) * (r - l + 1);
        }
      }
      long long lcp = A.ask(l, i + 1), lcs = B.ask(n + 1 - r, n + 1 - i + 1);
      if (lcp + lcs == (1 << j) - 2) {
        long long ps1 = l + lcp, ps2 = i + 1 + lcp;
        if (sum[r][a[i]] - sum[i][a[i]] == 0 && pd[(i + 1 + r) / 2][j - 1])
          tmp[ps1][a[ps2]] += (r - l + 1) * (r - l + 1);
        if (sum[i - 1][a[i]] - sum[l - 1][a[i]] == 0 &&
            pd[(l + i - 1) / 2][j - 1])
          tmp[ps2][a[ps1]] += (r - l + 1) * (r - l + 1);
      }
    }
  }
  for (long long i = 1; i <= n; i++)
    for (long long j = 0; j < 26; j++)
      if (j != a[i]) Ans = max(Ans, ans - pre[i] + tmp[i][j]);
  printf("%lld", Ans);
}