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 MOD = 1e9 + 7;
int s[100010][31];
int sum[100010];
long long num[100010];
long long f[100010], g[100010][31];
int h[100010][31];
char st[100010];
int n;
long long ans, anss;
int w[100010];
int a[100010];
inline int mo(int x) {
  if (x >= MOD) return x - MOD;
  return x;
}
void init() {
  for (int i = 1; i <= 26; i++)
    for (int j = 1; j <= n; j++) s[j][i] += s[j - 1][i];
  w[0] = 1;
  for (int i = 1; i <= n; i++) w[i] = 1ll * w[i - 1] * 37 % MOD;
  sum[0] = 0;
  for (int i = 1; i <= n; i++) sum[i] = mo(1ll * sum[i - 1] * 37 % MOD + a[i]);
  num[0] = 1;
  for (int i = 1; i < 20; i++)
    num[i] = 1ll * ((1 << (i + 1)) - 1) * ((1 << (i + 1)) - 1);
}
inline int calc(int x, int y) {
  return mo(sum[x + y - 1] - 1ll * sum[x - 1] * w[y] % MOD + MOD);
}
inline int query(int x, int y, int z) { return s[x + y - 1][z] - s[x - 1][z]; }
int main() {
  scanf("%s", st + 1);
  n = strlen(st + 1);
  for (int i = 1; i <= n; i++) a[i] = st[i] - 'a' + 1, s[i][a[i]]++;
  init();
  for (int i = 1; i <= n; i++) h[i][0] = 1;
  ans += n;
  for (int i = 1; i < 20; i++)
    for (int j = 1; j <= n - (1 << (i + 1)) + 2; j++) {
      if (!h[j][i - 1] || !h[j + (1 << i)][i - 1]) continue;
      if (calc(j, (1 << i) - 1) != calc(j + (1 << i), (1 << i) - 1)) continue;
      if (query(j, (1 << (i + 1)) - 1, a[j + (1 << i) - 1]) > 1) continue;
      h[j][i] = 1;
      ans += num[i];
      f[j] -= num[i];
      f[j + (1 << (i + 1)) - 1] += num[i];
    }
  anss = ans;
  for (int i = 1; i < 20; i++)
    for (int j = 1; j <= n - (1 << (i + 1)) + 2; j++) {
      if (h[j][i - 1] && h[j + (1 << i)][i - 1] &&
          calc(j, (1 << i) - 1) == calc(j + (1 << i), (1 << i) - 1)) {
        for (int k = 1; k <= 26; k++)
          if (!query(j, (1 << i) - 1, k)) g[j + (1 << i) - 1][k] += num[i];
      } else {
        int l = 0, r = (1 << i) - 1;
        while (l < r) {
          int mid = (l + r + 1) >> 1;
          if (calc(j, mid) == calc(j + (1 << i), mid))
            l = mid;
          else
            r = mid - 1;
        }
        if (calc(j + l + 1, (1 << i) - 1 - l - 1) !=
            calc(j + (1 << i) + l + 1, (1 << i) - 1 - l - 1))
          continue;
        if (h[j + (1 << i)][i - 1] &&
            !query(j + (1 << i), (1 << i) - 1, a[j + (1 << i) - 1])) {
          int c = calc(j + (1 << i) + l, 1);
          g[j + l][c] += num[i];
        }
        if (h[j][i - 1] && !query(j, (1 << i) - 1, a[j + (1 << i) - 1])) {
          int c = calc(j + l, 1);
          g[j + (1 << i) + l][c] += num[i];
        }
      }
    }
  for (int i = 1; i <= n; i++) {
    ans += f[i];
    for (int j = 1; j <= 26; j++) anss = max(anss, ans + g[i][j]);
  }
  printf("%lld\n", anss);
}