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 = 1e5 + 10, base = 13331;
int n, valid[MAXN][27];
int bucket[MAXN][27];
char s[MAXN];
unsigned long long power[MAXN], preh[MAXN];
long long w[MAXN], g[MAXN][27];
long long ans;
inline unsigned long long gethash(int i, int j) {
  if (i > j) return 0;
  return preh[j] - preh[i - 1] * power[j - i + 1];
}
inline int getcnt(int i, int j, char ch) {
  if (i > j) return 0;
  return bucket[j][ch - 'a' + 1] - bucket[i - 1][ch - 'a' + 1];
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  power[0] = 1;
  for (long long i = (1); i <= (n); i++) {
    preh[i] = preh[i - 1] * base + (s[i] - 'a' + 1);
    power[i] = power[i - 1] * base;
    for (long long j = (1); j <= (26); j++) bucket[i][j] = bucket[i - 1][j];
    bucket[i][s[i] - 'a' + 1]++;
  }
  for (long long i = (1); i <= (n); i++) valid[i][1] = 1;
  for (long long k = (2); k <= (29); k++) {
    for (long long i = (1); i <= (n); i++) {
      if (i + (1 << k) - 2 > n) break;
      int j = i + (1 << k) - 2;
      int mid = (i + j) / 2;
      valid[i][k] = (getcnt(i, j, s[mid]) == 1) &&
                    (valid[i][k - 1] && valid[mid + 1][k - 1]) &&
                    (gethash(i, mid - 1) == gethash(mid + 1, j));
    }
  }
  for (long long i = (1); i <= (n); i++) {
    for (long long k = (1); k <= (19); k++) {
      int len = (1 << k) - 1;
      int j = i + len - 1;
      if (valid[i][k])
        ans += (long long)len * len, w[i] += (long long)len * len,
            w[j + 1] -= (long long)len * len;
    }
  }
  for (long long i = (1); i <= (n); i++) w[i] += w[i - 1];
  for (long long i = (1); i <= (n); i++) {
    for (long long j = (1); j <= (26); j++) {
      g[i][j]++;
    }
    for (long long k = (2); k <= (19); k++) {
      int len = (1 << k) - 1;
      int j = i + len - 1;
      int mid = (i + j) / 2;
      if (j > n) break;
      if (gethash(i, mid - 1) == gethash(mid + 1, j)) {
        if (valid[i][k - 1] && valid[mid + 1][k - 1]) {
          for (long long x = (1); x <= (26); x++) {
            if (!getcnt(i, mid - 1, 'a' + x - 1))
              g[mid][x] += (long long)len * len;
          }
        }
      } else {
        int L = 1, R = (1 << (k - 1)) - 1, ret = 0;
        while (L <= R) {
          int MID = (L + R) >> 1;
          if (gethash(i, i + MID - 1) != gethash(mid + 1, mid + MID)) {
            ret = MID;
            R = MID - 1;
          } else {
            L = MID + 1;
          }
        }
        if (gethash(i + ret, mid - 1) != gethash(mid + ret + 1, j)) continue;
        if (valid[mid + 1][k - 1]) {
          if (!getcnt(mid + 1, j, s[mid]))
            g[i + ret - 1][s[mid + ret] - 'a' + 1] += (long long)len * len;
        }
        if (valid[i][k - 1]) {
          if (!getcnt(i, mid - 1, s[mid]))
            g[mid + ret][s[i + ret - 1] - 'a' + 1] += (long long)len * len;
        }
      }
    }
  }
  long long t = 0;
  for (long long i = (1); i <= (n); i++) {
    long long tmp = ans;
    for (long long j = (1); j <= (26); j++)
      tmp = (tmp > ans - w[i] + g[i][j] ? tmp : ans - w[i] + g[i][j]);
    t = (t > tmp ? t : tmp);
  }
  ans = t;
  printf("%lld", ans);
  return 0;
}