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;
inline char gc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline long long read() {
  long long x = 0;
  char ch = getchar();
  bool positive = 1;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') positive = 0;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return positive ? x : -x;
}
inline void write(long long a) {
  if (a >= 10) write(a / 10);
  putchar('0' + a % 10);
}
inline void writeln(long long a) {
  if (a < 0) {
    a = -a;
    putchar('-');
  }
  write(a);
  puts("");
}
const int N = 100005, base = 233, mod = 998244353;
char ch[N];
int n, pos, quan, ycl[N], sum[N][26], has[N];
long long dq, mx, ans, zs[26];
inline int Sum(int x, int y) {
  return sum[x][y] + (pos <= x ? (quan == y) - (ch[pos] == y) : 0);
}
inline int cal(int l, int r) {
  return (((has[r] - (long long)has[l] * ycl[r - l]) +
           ((l < pos && pos <= r) ? (long long)(quan - ch[pos]) * ycl[r - pos]
                                  : 0)) %
              mod +
          mod) %
         mod;
}
void dfs(int l, int r) {
  int tmp = r + 1;
  dq += (long long)(r - l + 1) * (r - l + 1);
  if (tmp * 2 - l <= n &&
      Sum(tmp * 2 - l, ch[tmp]) - Sum(l - 1, ch[tmp]) == 1 &&
      cal(l - 1, tmp - 1) == cal(tmp, tmp * 2 - l))
    dfs(l, tmp * 2 - l);
  tmp = l - 1;
  if (tmp * 2 - r > 0 && Sum(r, ch[tmp]) - Sum(tmp * 2 - r - 1, ch[tmp]) == 1 &&
      cal(tmp * 2 - r - 1, tmp - 1) == cal(tmp, r))
    dfs(tmp * 2 - r, r);
}
int yyy[N];
signed main() {
  scanf("%s", ch + 1);
  n = strlen(ch + 1);
  ycl[0] = 1;
  for (int i = 1; i <= n; i++) {
    ch[i] -= 'a';
    for (int j = 0; j < 26; j++) sum[i][j] = sum[i - 1][j];
    sum[i][ch[i]]++;
    has[i] = ((long long)has[i - 1] * base + ch[i]) % mod;
    ycl[i] = (long long)ycl[i - 1] * base % mod;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < i && i + j <= n; j = j * 2 + 1) {
      if (cal(i - j - 1, i - 1) != cal(i, i + j) ||
          sum[i + j][ch[i]] - sum[i - j - 1][ch[i]] > 1 ||
          yyy[i - (j + 1) / 2] < j / 2)
        break;
      ans += (long long)(j * 2 + 1) * (j * 2 + 1);
      yyy[i] = j;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int k = 0; k < 26; k++) {
      pos = i;
      quan = k;
      dq = ans;
      for (int j = 0; j < i && i + j <= n; j = j * 2 + 1) {
        if (cal(i - j - 1, i - 1) != cal(i, i + j) ||
            Sum(i + j, k) - Sum(i - j - 1, k) > 1 ||
            yyy[i - (j + 1) / 2] < j / 2)
          break;
        dfs(i - j, i + j);
      }
      zs[k] = dq;
    }
    for (int j = 0; j < 26; j++) {
      mx = max(mx, ans + zs[j] - zs[ch[i]]);
    }
  }
  cout << mx << endl;
}