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 = 100005;
char s[N];
int n, l[20];
int SA[N], rk[N];
int x[N], y[N], cnt[N];
int lg[N], st[18][N];
bool cmp(int i, int j, int k) {
  return y[i] != y[j] ||
         ((i + k > n ? -1 : y[i + k]) != (j + k > n ? -1 : y[j + k]));
}
void init_SA() {
  int m = 26;
  for (int i = (int)(1); i <= (int)(n); i++) cnt[x[i] = s[i] - 'a' + 1]++;
  for (int i = (int)(1); i <= (int)(m); i++) cnt[i] += cnt[i - 1];
  for (int i = (int)(n); i >= (int)(1); i--) SA[cnt[x[i]]--] = i;
  for (int k = 1; k <= n; k <<= 1) {
    int p = 0;
    for (int i = (int)(n - k + 1); i <= (int)(n); i++) y[++p] = i;
    for (int i = (int)(1); i <= (int)(n); i++)
      if (SA[i] > k) y[++p] = SA[i] - k;
    for (int i = (int)(0); i <= (int)(m); i++) cnt[i] = 0;
    for (int i = (int)(1); i <= (int)(n); i++) cnt[x[y[i]]]++;
    for (int i = (int)(1); i <= (int)(m); i++) cnt[i] += cnt[i - 1];
    for (int i = (int)(n); i >= (int)(1); i--) SA[cnt[x[y[i]]]--] = y[i];
    swap(x, y);
    m = x[SA[1]] = 1;
    for (int i = (int)(2); i <= (int)(n); i++)
      x[SA[i]] = (m += cmp(SA[i], SA[i - 1], k));
  }
  for (int i = (int)(1); i <= (int)(n); i++) rk[SA[i]] = i;
  int p = 0;
  for (int i = (int)(1); i <= (int)(n); i++)
    if (rk[i] != 1) {
      for (p -= (p != 0); s[i + p] == s[SA[rk[i] - 1] + p]; ++p)
        ;
      st[0][rk[i]] = p;
    }
  for (int i = (int)(2); i <= (int)(n); i++) lg[i] = lg[i / 2] + 1;
  for (int i = (int)(1); i <= (int)(16); i++)
    for (int j = (int)(1); j <= (int)(n - (1 << i) + 1); j++)
      st[i][j] = min(st[i - 1][j], st[i - 1][j + (1 << (i - 1))]);
}
int LCP(int x, int y) {
  x = rk[x];
  y = rk[y];
  if (x > y) swap(x, y);
  int k = lg[y - (++x) + 1];
  return min(st[k][x], st[k][y - (1 << k) + 1]);
}
int pr[N][26];
int fl[16][N];
long long S1[N], S2[N][26], ans;
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  init_SA();
  for (int i = (int)(1); i <= (int)(n); i++)
    for (int j = (int)(0); j <= (int)(25); j++)
      pr[i][j] = (j + 'a' == s[i] ? i : pr[i - 1][j]);
  for (int i = (int)(0); i <= (int)(15); i++) l[i] = (1 << (i + 1)) - 1;
  for (int i = (int)(1); i <= (int)(n); i++) fl[0][i] = 1;
  for (int i = (int)(1); i <= (int)(15); i++)
    for (int j = (int)(1); j <= (int)(n - l[i] + 1); j++)
      if (fl[i - 1][j] && fl[i - 1][j + (1 << i)] &&
          LCP(j, j + (1 << i)) >= l[i - 1])
        if (pr[j + l[i - 1] - 1][s[j + (1 << i) - 1] - 'a'] < j)
          if (pr[j + l[i] - 1][s[j + (1 << i) - 1] - 'a'] < j + (1 << i))
            fl[i][j] = 1;
  for (int i = (int)(0); i <= (int)(15); i++)
    for (int j = (int)(1); j <= (int)(n - l[i] + 1); j++)
      if (fl[i][j]) {
        ans += 1ll * l[i] * l[i];
        S1[j] += 1ll * l[i] * l[i];
        S1[j + l[i]] -= 1ll * l[i] * l[i];
      }
  for (int i = (int)(1); i <= (int)(n); i++) S1[i] += S1[i - 1];
  for (int i = (int)(1); i <= (int)(15); i++)
    for (int j = (int)(1); j <= (int)(n - l[i] + 1); j++)
      if (fl[i - 1][j] && fl[i - 1][j + (1 << i)] &&
          LCP(j, j + (1 << i)) >= l[i - 1])
        for (int k = (int)(0); k <= (int)(25); k++)
          if (pr[j + l[i - 1] - 1][k] < j && pr[j + l[i] - 1][k] < j + (1 << i))
            S2[j + (1 << i) - 1][k] += 1ll * l[i] * l[i];
  for (int i = (int)(1); i <= (int)(15); i++)
    for (int j = (int)(1); j <= (int)(n - l[i] + 1); j++)
      if (fl[i - 1][j] && pr[j + l[i - 1] - 1][s[j + (1 << i) - 1] - 'a'] < j) {
        int L1 = LCP(j, j + (1 << i));
        if (L1 >= l[i - 1]) continue;
        int L2 = LCP(j + L1 + 1, j + L1 + 1 + (1 << i));
        if (L1 + L2 + 1 < l[i - 1]) continue;
        S2[j + L1 + (1 << i)][s[j + L1] - 'a'] += 1ll * l[i] * l[i];
      }
  for (int i = (int)(1); i <= (int)(15); i++)
    for (int j = (int)(1); j <= (int)(n - l[i] + 1); j++)
      if (fl[i - 1][j + (1 << i)] &&
          pr[j + l[i] - 1][s[j + (1 << i) - 1] - 'a'] < j + (1 << i)) {
        int L1 = LCP(j, j + (1 << i));
        if (L1 >= l[i - 1]) continue;
        int L2 = LCP(j + L1 + 1, j + L1 + 1 + (1 << i));
        if (L1 + L2 + 1 < l[i - 1]) continue;
        S2[j + L1][s[j + L1 + (1 << i)] - 'a'] += 1ll * l[i] * l[i];
      }
  long long dif = 0;
  for (int i = (int)(1); i <= (int)(n); i++)
    for (int j = (int)(0); j <= (int)(25); j++)
      dif = max(dif, S2[i][j] + 1 - S1[i]);
  printf("%lld\n", dif + ans);
}