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 = 222222, inf = ~0U >> 1;
const int seed = 13131;
vector<pair<int, int> > way[20][maxn];
bool ok[20][maxn];
unsigned long long powHash[maxn], valHash[maxn];
int n, cnt[26][maxn];
long long ans[26][maxn], lsum[maxn], rsum[maxn];
char s[maxn];
inline unsigned long long val(int l, int r) {
  return valHash[r + 1] - valHash[l] * powHash[r - l + 1];
}
inline int occur(int letter, int l, int r) {
  if (!l)
    return cnt[letter][r];
  else
    return cnt[letter][r] - cnt[letter][l - 1];
}
inline long long calc(int w) {
  return 1ll * ((1 << (w + 1)) - 1) * ((1 << (w + 1)) - 1);
}
inline void solve(int p, int mk, int md, int k) {
  int ret = 0;
  if (p == md) {
    if (val(md - (1 << (k)) + 1, md - 1) == val(md + 1, md + (1 << (k)) - 1) &&
        ok[k - 1][md - (1 << (k - 1))])
      for (int letter = 0; letter < 26; letter++) {
        int allow = letter == s[md] - 'a' ? 1 : 0;
        if (occur(letter, md - (1 << (k)) + 1, md + (1 << (k)) - 1) <= allow)
          ret |= (1 << (letter));
      }
  } else {
    int p1, p2, letter;
    if (p < md)
      p1 = p, p2 = p + (1 << (k)), letter = s[p2] - 'a';
    else
      p1 = p - (1 << (k)), p2 = p, letter = s[p1] - 'a';
    if (mk & (1 << (letter)))
      if (val(md - (1 << (k)) + 1, p1 - 1) == val(md + 1, p2 - 1) &&
          val(p1 + 1, md - 1) == val(p2 + 1, md + (1 << (k)) - 1))
        if (letter != s[md] - 'a') {
          int mid_letter = s[md] - 'a';
          int allow = s[p] == s[md] ? 2 : 1;
          if (occur(mid_letter, md - (1 << (k)) + 1, md + (1 << (k)) - 1) <=
              allow)
            ret |= (1 << (letter));
        }
  }
  if (ret) way[k][md].push_back(make_pair(p, ret));
}
int main() {
  scanf("%s", s);
  n = strlen(s);
  for (int i = 0; i < n; i++) ++cnt[s[i] - 'a'][i];
  for (int i = 0; i < 26; i++)
    for (int j = 0; j < n; j++) cnt[i][j + 1] += cnt[i][j];
  powHash[0] = 1;
  for (int i = 0; i < n; i++) powHash[i + 1] = powHash[i] * seed;
  valHash[0] = 1;
  for (int i = 0; i < n; i++) valHash[i + 1] = valHash[i] * seed + s[i];
  for (int i = 0; i < n; i++)
    way[0][i].push_back(make_pair(i, (1 << (26)) - 1)), ok[0][i] = true;
  for (int k = 1; k < 17; ++k)
    for (int i = (1 << (k)) - 1; i <= n - (1 << (k)); ++i) {
      for (__typeof(way[k - 1][i - (1 << (k - 1))].begin()) it =
               way[k - 1][i - (1 << (k - 1))].begin();
           it != way[k - 1][i - (1 << (k - 1))].end(); it++)
        solve(it->first, it->second, i, k);
      for (__typeof(way[k - 1][i + (1 << (k - 1))].begin()) it =
               way[k - 1][i + (1 << (k - 1))].begin();
           it != way[k - 1][i + (1 << (k - 1))].end(); it++)
        solve(it->first, it->second, i, k);
      solve(i, (1 << (26)) - 1, i, k);
      for (__typeof(way[k][i].begin()) it = way[k][i].begin();
           it != way[k][i].end(); it++)
        if (it->second & (1 << (s[it->first] - 'a'))) ok[k][i] = true;
    }
  for (int k = 0; k < 17; k++)
    for (int i = 0; i < n; i++)
      for (__typeof(way[k][i].begin()) it = way[k][i].begin();
           it != way[k][i].end(); it++)
        for (int letter = 0; letter < 26; letter++)
          if (it->second & (1 << (letter))) ans[letter][it->first] += calc(k);
  for (int k = 0; k < 17; k++)
    for (int i = 0; i < n; i++)
      if (ok[k][i])
        lsum[i - (1 << (k))] += calc(k), rsum[i + (1 << (k))] += calc(k);
  for (int i = n - 1; i >= 0; i--) lsum[i] += lsum[i + 1];
  for (int i = 0; i < n; i++) rsum[i] += rsum[i - 1];
  long long Ans = 0;
  for (int i = 0; i < n; i++)
    for (int letter = 0; letter < 26; letter++)
      Ans = max(Ans, ans[letter][i] + lsum[i] + rsum[i]);
  cout << Ans << endl;
  return 0;
}