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 = 100050;
const int limit = 16;
const int h = 31;
int n;
int len[maxn];
long long ans, inc;
long long cost[maxn];
long long bef[maxn][30];
unsigned long long ha[maxn], mi[maxn];
int sum[30][maxn];
char s[maxn];
bool pef[maxn][limit + 5];
inline unsigned long long sub(int l, int r) {
  return ha[r] - ha[l - 1] * mi[r - l + 1];
}
inline bool check(int l1, int r1, int l2, int r2) {
  return sub(l1, r1) == sub(l2, r2);
}
inline int lcp(int l1, int l2) {
  int res = 0;
  for (int i = limit; i >= 0; --i) {
    int le = res + len[i];
    if (l1 + le <= n && l2 + le <= n && check(l1, l1 + le, l2, l2 + le))
      res += len[i] + 1;
  }
  return res;
}
inline void init() {
  for (int i = 1; i <= limit + 1; ++i) len[i] = len[i - 1] << 1 | 1;
  mi[0] = 1, ans = n = strlen(s + 1);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= 26; ++j)
      sum[j][i] = sum[j][i - 1] + (s[i] - 'a' + 1 == j);
    pef[i][1] = true, mi[i] = mi[i - 1] * h;
    ha[i] = ha[i - 1] * h + s[i] - 'a' + 1;
  }
}
inline void get_pef() {
  for (int i = 2; len[i] <= n; ++i)
    for (int l = 1, r = len[i]; r <= n; ++l, ++r) {
      int mid = l + len[i - 1], ch = s[mid] - 'a' + 1;
      if (sum[ch][r] - sum[ch][l - 1] == 1)
        pef[l][i] =
            pef[l][i - 1] & pef[mid + 1][i - 1] & check(l, mid - 1, mid + 1, r);
      ans += 1ll * pef[l][i] * len[i] * len[i];
    }
}
inline void get_cost() {
  for (int i = 1; len[i] <= n; ++i)
    for (int l = 1, r = len[i]; r <= n; ++l, ++r) {
      cost[l] += 1ll * pef[l][i] * len[i] * len[i];
      cost[r + 1] -= 1ll * pef[l][i] * len[i] * len[i];
    }
  for (int i = 1; i <= n; ++i) cost[i] += cost[i - 1];
}
inline void calc(int l1, int k) {
  if (k == 1) {
    for (int i = 1; i <= 26; ++i) ++bef[l1][i];
    return;
  }
  int mid = l1 + len[k - 1], l2 = mid + 1;
  long long tmp = 1ll * len[k] * len[k];
  if (pef[l1][k - 1] && pef[l2][k - 1] &&
      check(l1, mid - 1, l2, l2 + len[k - 1] - 1))
    for (int i = 1; i <= 26; ++i)
      if (sum[i][l1 - 1] == sum[i][mid - 1]) bef[mid][i] += tmp;
  int prf1 = lcp(l1, l2);
  if (prf1 >= len[k - 1]) return;
  int m1 = l1 + prf1, m2 = l2 + prf1;
  int prf2 = lcp(m1 + 1, m2 + 1);
  if (m1 + 1 + prf2 < mid) return;
  if (pef[l1][k - 1] &&
      sum[s[mid] - 'a' + 1][l1 - 1] == sum[s[mid] - 'a' + 1][mid - 1])
    bef[m2][s[m1] - 'a' + 1] += tmp;
  if (pef[l2][k - 1] &&
      sum[s[mid] - 'a' + 1][mid] == sum[s[mid] - 'a' + 1][l2 + len[k - 1] - 1])
    bef[m1][s[m2] - 'a' + 1] += tmp;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> (s + 1);
  init();
  get_pef();
  get_cost();
  for (int i = 1; i <= n; ++i)
    for (int j = 1; i + len[j] - 1 <= n; ++j) calc(i, j);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= 26; ++j) inc = max(inc, bef[i][j] - cost[i]);
  cout << ans + inc << endl;
  return 0;
}