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;
clock_t __stt;
inline void TStart() { __stt = clock(); }
inline void TReport() {
  printf("\nTaken Time : %.3lf sec\n",
         (double)(clock() - __stt) / CLOCKS_PER_SEC);
}
template <typename T>
T MIN(T a, T b) {
  return a < b ? a : b;
}
template <typename T>
T MAX(T a, T b) {
  return a > b ? a : b;
}
template <typename T>
T ABS(T a) {
  return a > 0 ? a : (-a);
}
template <typename T>
void UMIN(T &a, T b) {
  if (b < a) a = b;
}
template <typename T>
void UMAX(T &a, T b) {
  if (b > a) a = b;
}
int n, ct[100005][30], len[16], hs[100005], mul[100005];
char s[100005];
long long commit[100005][30], df[100005][30], res;
class ST {
 public:
  bool ok;
  vector<pair<int, int> > vc;
  ST(int OK = 0) {
    vc.clear();
    ok = OK;
  }
  void Not(int val) {
    int xb;
    vector<pair<int, int> > nvc;
    nvc.clear();
    for (xb = 0; xb < (int)vc.size(); ++xb)
      if (vc[xb].second != val) nvc.push_back(vc[xb]);
    vc = nvc;
    nvc.clear();
  }
  void output() {
    if (ok) {
      printf("All\n");
    } else {
      int xb;
      for (xb = 0; xb < (int)vc.size(); ++xb) {
        printf("{%d,%c}", vc[xb].first, vc[xb].second);
      }
      printf("\n");
    }
  }
} dp[16][100005];
ST And(ST &a, ST &b) {
  int xb = 0, x2 = 0;
  if (a.ok) return b;
  if (b.ok) return a;
  ST x;
  while (xb < (int)a.vc.size() && x2 < (int)b.vc.size()) {
    if (a.vc[xb] == b.vc[x2]) {
      x.vc.push_back(a.vc[xb]);
      ++xb;
      ++x2;
    } else if (a.vc[xb] < b.vc[x2])
      ++xb;
    else
      ++x2;
  }
  return x;
}
inline bool cmp(int a, int b, int c, int d) {
  long long val1, val2;
  if (b - a != d - c) return 0;
  if (b < a && d < c) return 1;
  if (a)
    val1 = hs[b] - hs[a - 1] * mul[b - a + 1];
  else
    val1 = hs[b];
  if (c)
    val2 = hs[d] - hs[c - 1] * mul[d - c + 1];
  else
    val2 = hs[d];
  return val1 == val2;
}
inline int lcp(int a, int b, int c, int d) {
  int low = 0, high = b - a + 1, mid;
  while (low < high) {
    mid = ((low + high + 1) >> 1);
    if (cmp(a, a + mid - 1, c, c + mid - 1))
      low = mid;
    else
      high = mid - 1;
  }
  return low;
}
inline int dif(int a, int b, int c, int d) {
  int ilen = lcp(a, b, c, d);
  if (ilen == b - a + 1) return -1;
  if (ilen == b - a) return ilen;
  if (a + ilen + lcp(a + ilen + 1, b, c + ilen + 1, d) >= b)
    return ilen;
  else
    return -2;
}
inline int cnt(int l, int r, char c) {
  if (l) return ct[r][c - 'a'] - ct[l - 1][c - 'a'];
  return ct[r][c - 'a'];
}
int main() {
  scanf("%s", s);
  n = strlen(s);
  int xb, x2, x3;
  mul[0] = 1;
  for (xb = 1; xb <= n; ++xb) mul[xb] = mul[xb - 1] * 43;
  for (xb = 0; xb < n; ++xb) ++ct[xb][s[xb] - 'a'];
  for (xb = 1; xb < n; ++xb)
    for (x2 = 0; x2 < 26; ++x2) ct[xb][x2] += ct[xb - 1][x2];
  hs[0] = s[0];
  for (xb = 1; xb < n; ++xb) hs[xb] = hs[xb - 1] * 43 + (int)s[xb];
  len[0] = 1;
  for (xb = 1; xb < 16; ++xb) len[xb] = len[xb - 1] * 2 + 1;
  for (xb = 0; xb < 16; ++xb) {
    for (x2 = 0; x2 < n; ++x2) {
      if (x2 + len[xb] - 1 >= n) break;
      int lv = x2, rv = x2 + len[xb] - 1, mv = x2 + (len[xb] - 1) / 2;
      long long adv = ((long long)(rv - lv + 1)) * ((long long)(rv - lv + 1));
      if (xb > 0)
        dp[xb][x2] = And(dp[xb - 1][x2], dp[xb - 1][mv + 1]);
      else
        dp[xb][x2] = ST(1);
      int vv = dif(lv, mv - 1, mv + 1, rv);
      if (vv == -2) {
        dp[xb][x2].ok = 0;
        dp[xb][x2].vc.clear();
      } else if (vv != -1) {
        ST x;
        x.vc.push_back(make_pair(lv + vv, s[mv + vv + 1]));
        x.vc.push_back(make_pair(mv + vv + 1, s[lv + vv]));
        dp[xb][x2] = And(dp[xb][x2], x);
      }
      dp[xb][x2].Not(s[mv]);
      if (cnt(lv, rv, s[mv]) > 2 && !(cnt(lv, rv, s[mv]) & 1)) {
        dp[xb][x2].ok = 0;
        dp[xb][x2].vc.clear();
      } else if (cnt(lv, rv, s[mv]) > 2) {
        ST x;
        for (x3 = 'a'; x3 <= 'z'; ++x3)
          if (cnt(lv, rv, x3) == 0) x.vc.push_back(make_pair(mv, x3));
        dp[xb][x2] = And(dp[xb][x2], x);
      }
      if (dp[xb][x2].ok) {
        res += adv;
        for (x3 = 0; x3 < 26; ++x3) {
          if (cnt(lv, rv, x3 + 'a') == 0) commit[mv][x3] += adv;
          df[0][x3] += adv;
          df[lv][x3] -= adv;
          df[rv + 1][x3] += adv;
        }
      } else
        for (x3 = 0; x3 < (int)dp[xb][x2].vc.size(); ++x3) {
          commit[dp[xb][x2].vc[x3].first][dp[xb][x2].vc[x3].second - 'a'] +=
              adv;
        }
    }
  }
  for (xb = 0; xb < n; ++xb)
    for (x2 = 0; x2 < 26; ++x2) {
      if (xb) df[xb][x2] += df[xb - 1][x2];
      UMAX(res, commit[xb][x2] + df[xb][x2]);
    }
  printf("%I64d\n", res);
  return 0;
}