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;
template <typename T1, typename T2>
inline T1 max(T1 a, T2 b) {
  return a < b ? b : a;
}
template <typename T1, typename T2>
inline T1 min(T1 a, T2 b) {
  return a < b ? a : b;
}
const char lf = '\n';
namespace ae86 {
const int bufl = 1 << 15;
char buf[bufl], *s = buf, *t = buf;
inline int fetch() {
  if (s == t) {
    t = (s = buf) + fread(buf, 1, bufl, stdin);
    if (s == t) return EOF;
  }
  return *s++;
}
inline int ty() {
  int a = 0;
  int b = 1, c = fetch();
  while (!isdigit(c)) b ^= c == '-', c = fetch();
  while (isdigit(c)) a = a * 10 + c - 48, c = fetch();
  return b ? a : -a;
}
template <typename T>
inline int ts(T *s) {
  int a = 0, c = fetch();
  while (c <= 32 && c != EOF) c = fetch();
  while (c > 32 && c != EOF) s[a++] = c, c = fetch();
  s[a] = 0;
  return a;
}
}  // namespace ae86
using ae86::ts;
using ae86::ty;
const int _ = 100007, alp = 26;
const unsigned long long bas = 1145141;
unsigned long long ha[_] = {0}, ba[_] = {0};
int n, val[_], cnt[_][alp] = {0};
unsigned long long hashie(int l, int r) {
  return ha[r] - ha[l - 1] * ba[r - l + 1];
}
int tims(int l, int r, int x) { return cnt[r][x] - cnt[l - 1][x]; }
int able[_][21] = {0};
long long chaf[_] = {0};
long long got = 0;
void dfs(int l, int r, unsigned long long hs) {
  int len = r - l + 1;
  got += 1ll * len * len;
  if (r + len + 1 <= n && hs == hashie(r + 2, r + len + 1) &&
      !tims(r + 2, r + len + 1, val[r + 1] - 'a'))
    dfs(l, r + len + 1, hs * ba[len + 1] + hashie(r + 1, r + len + 1));
  if (l - 1 - len >= 1 && hs == hashie(l - len - 1, l - 2) &&
      !tims(l - len - 1, l - 2, val[l - 1] - 'a'))
    dfs(l - len - 1, r, hashie(l - len - 1, l - 1) * ba[len] + hs);
}
int main() {
  ios::sync_with_stdio(0), cout.tie(nullptr);
  n = ts(val + 1);
  for (int i = 1; i <= n; i++)
    memcpy(cnt[i], cnt[i - 1], sizeof(cnt[i])), cnt[i][val[i] - 'a']++;
  ba[0] = 1;
  for (int i = 1; i <= n; i++)
    ha[i] = ha[i - 1] * bas + val[i], ba[i] = ba[i - 1] * bas;
  long long sval = 0;
  for (int i = 0, now = 1; now <= n; i++, now = now + now + 1)
    for (int j = 1; j <= n - now + 1; j++) {
      int a = j + now / 2, b = j + now - 1;
      if (!i || (hashie(j, a - 1) == hashie(a + 1, b) &&
                 tims(j, b, val[a] - 'a') == 1 && able[j][i - 1] &&
                 able[a + 1][i - 1])) {
        long long dlt = 1ll * now * now;
        sval += dlt, chaf[j] += dlt, chaf[b + 1] -= dlt, able[j][i] = 1;
      }
    }
  for (int i = 1; i <= n; i++) chaf[i] += chaf[i - 1];
  long long ans = sval;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < alp; j++) {
      got = sval - chaf[i];
      for (int k = 0, now = 0; now <= n; k++, now = now + now + 1) {
        int l = i - now, r = i + now;
        if (l < 1 || r > n) break;
        if (!k || (hashie(l, i - 1) == hashie(i + 1, r) && !tims(l, i - 1, j) &&
                   !tims(i + 1, r, j) && able[l][k - 1] && able[i + 1][k - 1]))
          dfs(l, r,
              hashie(l, i - 1) * ba[now + 1] + ('a' + j) * ba[now] +
                  hashie(i + 1, r));
        else
          break;
      }
      ans = max(ans, got);
    }
  }
  cout << ans << lf;
  return 0;
}