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>
const int N = 100000 + 10, S = 26, B = 31;
int n;
char s[N];
unsigned long long val[N], mem[N];
inline unsigned long long hash(int l, int r) {
  return l > r ? 0 : (val[r] - val[l - 1] * mem[r - l + 1]);
}
int len[S];
int sum[S][N];
inline int get(int p, int l, int r) { return sum[p][r] - sum[p][l - 1]; }
int bSearch(int p, int q, int r) {
  int l = 0;
  while (l < r) {
    int mid = (l + r + 1) >> 1;
    if (hash(p, p + mid - 1) == hash(q, q + mid - 1))
      l = mid;
    else
      r = mid - 1;
  }
  return l;
}
int main() {
  mem[0] = 1;
  for (int i = 1; i < N; ++i) mem[i] = B * mem[i - 1];
  len[0] = 1;
  for (int i = 1; i < S; ++i) len[i] = 2 * len[i - 1] + 1;
  scanf(" %s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; ++i) val[i] = B * val[i - 1] + s[i] - 'a' + 1;
  static bool flag[S][N];
  for (int i = 1; i <= n; ++i) flag[0][i] = true;
  for (int i = 0; i < S; ++i)
    for (int j = 1; j <= n; ++j) sum[i][j] = sum[i][j - 1] + (s[j] - 'a' == i);
  static long long det[N][S], tag[N];
  long long ans = n;
  for (int j = 1; j < S; ++j) {
    int a = len[j - 1], b = len[j];
    for (int i = 1; i + b - 1 <= n; ++i) {
      if (!flag[j - 1][i] && !flag[j - 1][i + a + 1]) continue;
      int t = bSearch(i, i + a + 1, a);
      if (hash(i + t + 1, i + a - 1) != hash(i + a + 1 + t + 1, i + b - 1))
        continue;
      if (t < a) {
        int p = i + t, q = i + a + 1 + t;
        if (flag[j - 1][i + a + 1] && get(s[i + a] - 'a', i, i + b - 1) -
                                              (s[p] == s[i + a]) +
                                              (s[q] == s[i + a]) ==
                                          1)
          det[p][s[q] - 'a'] += (long long)b * b;
        if (flag[j - 1][i] && get(s[i + a] - 'a', i, i + b - 1) -
                                      (s[q] == s[i + a]) + (s[p] == s[i + a]) ==
                                  1)
          det[q][s[p] - 'a'] += (long long)b * b;
      } else {
        if (!flag[j - 1][i] || !flag[j - 1][i + a + 1]) continue;
        if (get(s[i + a] - 'a', i, i + b - 1) == 1) {
          flag[j][i] = true;
          tag[i] -= (long long)b * b;
          tag[i + b] += (long long)b * b;
          ans += (long long)b * b;
          for (int k = 0; k < S; ++k)
            if (get(k, i, i + b - 1) - (s[i + a] - 'a' == k) == 0)
              det[i + a][k] += (long long)b * b;
        } else {
          for (int k = 0; k < S; ++k)
            if (!get(k, i, i + b - 1)) det[i + a][k] += (long long)b * b;
        }
      }
    }
  }
  for (int i = 1; i <= n; ++i) tag[i] += tag[i - 1];
  long long temp = 0;
  for (int i = 1; i <= n; ++i)
    temp = std::max(temp, tag[i] + *std::max_element(det[i], det[i] + S));
  printf("%lld\n", ans + temp);
  return 0;
}