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 MAXN = 210000;
char a[MAXN];
unsigned long long ha[MAXN], po[MAXN];
const unsigned long long base = 99999997ll;
int sum[MAXN][27];
int n;
int na, nb;
map<int, bool> hf[MAXN];
inline unsigned long long getLR(int l, int r) {
  return ha[r] - ha[l - 1] * po[r - l + 1];
}
inline int num(int l, int r, int d) { return sum[r][d] - sum[l - 1][d]; }
bool ck(int l, int r) {
  if (l == r) return 1;
  if (hf[l].find(r) != hf[l].end()) return hf[l][r];
  int mid = (l + r) >> 1;
  bool flag = 1;
  if (num(l, mid - 1, a[mid] - 'a') != 0) flag = 0;
  if (num(mid + 1, r, a[mid] - 'a') != 0) flag = 0;
  if (getLR(l, mid - 1) != getLR(mid + 1, r)) flag = 0;
  flag &= ck(l, mid - 1);
  flag &= ck(mid + 1, r);
  hf[l][r] = flag;
  return flag;
}
long long old[MAXN];
long long res = 0;
long long dfs(int l, int r, unsigned long long hp) {
  long long rp = (r - l + 1) * 1ll * (r - l + 1);
  int len = (r - l + 1);
  if (r + 1 + len <= n)
    if (!num(r + 2, r + 1 + len, a[r + 1] - 'a') &&
        hp == getLR(r + 2, r + 1 + len))
      rp += dfs(l, r + 1 + len,
                (hp + hp * po[len + 1] + (a[r + 1] - 'a') * po[len]));
  if (l - 1 - len >= 1)
    if (!num(l - 1 - len, l - 2, a[l - 1] - 'a') &&
        hp == getLR(l - 1 - len, l - 2))
      rp += dfs(l - 1 - len, r,
                (hp + hp * po[len + 1] + (a[l - 1] - 'a') * po[len]));
  return rp;
}
int main() {
  scanf("%s", a + 1);
  n = strlen(a + 1);
  po[0] = 1;
  for (int i = (1); i <= (int)n; i++) {
    ha[i] = ha[i - 1] * base;
    ha[i] += 1ll * (a[i] - 'a');
    po[i] = po[i - 1] * base;
    for (int j = (0); j <= (int)25; j++) sum[i][j] = sum[i - 1][j];
    sum[i][a[i] - 'a']++;
  }
  for (int i = (1); i <= (int)n; i++)
    for (int j = 1; i + j <= n && i - j >= 1; j = j * 2 + 1)
      if (ck(i - j, i + j)) {
        int l = i - j;
        int r = i + j;
        res += (r - l + 1) * 1ll * (r - l + 1);
        old[l] += (r - l + 1) * 1ll * (r - l + 1);
        old[r + 1] -= (r - l + 1) * 1ll * (r - l + 1);
      }
  res += 1ll * n;
  long long ans = res;
  for (int i = (1); i <= (int)n; i++) old[i] += old[i - 1];
  for (int i = (1); i <= (int)n; i++) old[i]++;
  for (int i = (1); i <= (int)n; i++)
    for (int j = (0); j <= (int)25; j++) {
      na = i;
      nb = j;
      long long tmp = res - old[i];
      tmp += dfs(i, i, j);
      for (int len = 1; len + i <= n && i - len >= 1; len = len * 2 + 1)
        if (ck(i - len, i - 1) && ck(i + 1, i + len) &&
            !num(i - len, i - 1, j) && !num(i + 1, i + len, j) &&
            getLR(i - len, i - 1) == getLR(i + 1, i + len))
          tmp += dfs(i - len, i + len,
                     getLR(i - len, i + len) + (j - (a[i] - 'a')) * po[len]);
      ans = max(ans, tmp);
    }
  printf("%I64d\n", ans);
  return 0;
}