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 Advance = 233;
int n, cnt[26][100005];
char s[100005];
bool gray[22][100005];
long long unchange, cost[100005], add[100005][26];
unsigned long long hashl[100005], pw[100005];
void initHash() {
  hashl[0] = s[0] - 'a';
  pw[0] = 1;
  for (int i = 1; i < n; i++) {
    hashl[i] = hashl[i - 1] * Advance + s[i] - 'a';
    pw[i] = pw[i - 1] * Advance;
  }
}
inline unsigned long long getHash(int l, int r) {
  unsigned long long res = 0;
  if (l > r) return res;
  res = hashl[r];
  if (l != 0) res = hashl[r] - hashl[l - 1] * pw[r - l + 1];
  return res;
}
inline unsigned long long getHashExcept(int l, int r, int p) {
  unsigned long long res = getHash(l, r);
  res -= (s[p] - 'a') * pw[r - p];
  return res;
}
inline int common(int a, int b) {
  int first = 0, last = min(n - a, n - b);
  while (first <= last) {
    int mid = (first + last) / 2;
    if (getHash(a, a + mid - 1) == getHash(b, b + mid - 1))
      first = mid + 1;
    else
      last = mid - 1;
  }
  return last;
}
inline bool notExist(int a, int b, int c) {
  if (a == 0) return cnt[c][b] == 0;
  return cnt[c][b] == cnt[c][a - 1];
}
long long init() {
  for (int i = 0; i < 26; i++) {
    cnt[i][0] = (s[0] == i + 'a');
    for (int j = 1; j < n; j++) cnt[i][j] = cnt[i][j - 1] + (s[j] == i + 'a');
  }
  long long res = 0;
  cost[0] = 1;
  for (int i = 0; i < n; i++) {
    gray[0][i] = true;
    res++;
  }
  for (int level = 1; level <= 17; level++) {
    int r = (1 << level) - 1;
    for (int i = r; i < n - r; i++) {
      if (gray[level - 1][i - (r + 1) / 2] &&
          getHash(i - r, i - 1) == getHash(i + 1, i + r) &&
          notExist(i - r, i - 1, s[i] - 'a')) {
        gray[level][i] = true;
        long long curr = r * 2 + 1;
        curr *= curr;
        res += curr;
        cost[i - r] += curr;
        cost[i + r + 1] -= curr;
      }
    }
  }
  for (int i = 1; i < n; i++) cost[i] += cost[i - 1];
  return res;
}
void process(int level, int i) {
  if (level == 0) {
    for (int j = 0; j < 26; j++) add[i][j]++;
    return;
  }
  int r = (1 << level) - 1;
  if (i - r < 0 || i + r >= n) return;
  long long curr = r * 2 + 1;
  curr *= curr;
  int a = i - r, b = i + 1, lr = (r + 1) / 2;
  if (getHash(a, i - 1) == getHash(b, i + r) && gray[level - 1][i - lr]) {
    for (int j = 0; j < 26; j++) {
      if (notExist(b, i + r, j)) {
        add[i][j] += curr;
      }
    }
  } else {
    int len = common(a, b);
    if (len >= r) return;
    int l2 = common(a + len + 1, b + len + 1);
    if (len + l2 + 1 < r) return;
    int op = 0;
    if (gray[level - 1][i + lr] && notExist(i + 1, i + r, s[i] - 'a'))
      add[a + len][s[b + len] - 'a'] += curr, op |= 1;
    if (gray[level - 1][i - lr] && notExist(i - r, i - 1, s[i] - 'a'))
      add[b + len][s[a + len] - 'a'] += curr, op |= 2;
  }
}
int main() {
  scanf("%s", s);
  n = strlen(s);
  initHash();
  unchange = init();
  for (int level = 0; level <= 17; level++)
    for (int i = 0; i < n; i++) process(level, i);
  long long res = unchange;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < 26; j++)
      if (j != s[i] - 'a') {
        res = max(res, add[i][j] - cost[i] + unchange);
      }
  printf("%lld\n", res);
  return 0;
}