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;
void read(int& x) {
  bool fu = 0;
  char c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  if (c == '-') fu = 1, c = getchar();
  for (x = 0; c > 32; c = getchar()) x = x * 10 + c - '0';
  if (fu) x = -x;
};
char getc() {
  char c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  return c;
}
const int N = 100010;
const int D = 400010;
const int mod = 1000000007;
int n, i, j, k, l, r, l2, r2, p, t, t2, ch, cw, pcnt;
char s[N];
int ha[N], powc[N];
long long ans, delta;
bool s0[N][21];
int pt[N][21];
long long dd[27][N];
void hashpre() {
  int i, j, k, l, p;
  powc[0] = 1;
  for (i = 1; i <= n; i++) powc[i] = 1LL * powc[i - 1] * 26 % mod;
  for (i = 1; i <= n; i++) ha[i] = (1LL * ha[i - 1] * 26 + (s[i] - 'a')) % mod;
}
int geth(int x, int y) {
  return ((ha[y] - 1LL * ha[x - 1] * powc[y - x + 1]) % mod + mod) % mod;
}
int LCP(int i, int j) {
  if (s[i] != s[j]) return 0;
  int l = 1, r = min(n - i + 1, n - j + 1), mid;
  while (l < r) {
    mid = (l + r + 1) / 2;
    if (geth(i, i + mid - 1) == geth(j, j + mid - 1))
      l = mid;
    else
      r = mid - 1;
  }
  return l;
}
int V[26][N];
int pdone(int c, int x, int y) {
  return (upper_bound(V[c] + 1, V[c] + 1 + V[c][0], y) - V[c]) -
         (lower_bound(V[c] + 1, V[c] + 1 + V[c][0], x) - V[c]);
}
long long add[D];
void find(int i, int x, int y, int l, int r, long long s) {
  if (y < l || x > r) return;
  if (x >= l && y <= r) {
    add[i] += s;
    return;
  }
  find(i * 2, x, (x + y) / 2, l, r, s);
  find(i * 2 + 1, (x + y) / 2 + 1, y, l, r, s);
}
void go(int i, int x, int y, long long sum) {
  sum += add[i];
  if (x != y) {
    go(i * 2, x, (x + y) / 2, sum);
    go(i * 2 + 1, (x + y) / 2 + 1, y, sum);
  } else {
    int k, kk;
    long long best = 0;
    for (k = 0; k <= 25; k++)
      if (k != s[x] - 'a') {
        if (dd[k][x] > best) best = dd[k][x], kk = k;
      }
    if (sum + best > delta) {
      delta = sum + best;
    }
  }
}
long long value(long long x) { return ((1LL << x) - 1) * ((1LL << x) - 1); }
bool check(int j, int l, int r, int w, int c) {
  int i = (l + r) / 2;
  if (w == i) {
    if (j == 0)
      return (pdone(c, l, r) == 0);
    else
      return (pdone(c, l, r) == 0) && s0[i - (1 << (j - 1))][j - 1] &&
             s0[i + (1 << (j - 1))][j - 1];
  }
  if (pt[i][j] - (s[w] == s[i]) + (s[i] - 'a' == c) > 1) return 0;
  if (w > (l + r) / 2)
    return s0[i - (1 << (j - 1))][j - 1] && check(j - 1, i + 1, r, w, c);
  else
    return s0[i + (1 << (j - 1))][j - 1] && check(j - 1, l, i - 1, w, c);
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  char c;
  for (i = 1; i <= n; i++) {
    c = s[i] - 'a';
    V[c][++V[c][0]] = i;
  }
  hashpre();
  for (i = 1; i <= n; i++) s0[i][0] = 1, ans++;
  bool pd, thepd, same;
  for (j = 1; j <= 20; j++) {
    for (i = 1; i <= n; i++) {
      l = i - (1 << j) + 1;
      r = i + (1 << j) - 1;
      l2 = i - (1 << (j - 1));
      r2 = i + (1 << (j - 1));
      if (l <= 0 || r > n) continue;
      pcnt = pdone(s[i] - 'a', l, r);
      pt[i][j] = pcnt;
      thepd = (pcnt <= 1);
      same = geth(l, i - 1) == geth(i + 1, r);
      if (same && s0[l2][j - 1] && s0[r2][j - 1] && thepd) {
        s0[i][j] = 1;
        find(1, 1, n, l, r, -value(j + 1));
        ans += value(j + 1);
      }
      if (i == 6 && j == 2) {
        int o = 1;
      }
      if (same && s0[l2][j - 1] && s0[r2][j - 1]) {
        for (k = 0; k <= 25; k++)
          if (k != s[i] - 'a')
            if (pdone(k, l, r) == 0) dd[k][i] += value(j + 1);
      }
      if (!same) {
        t = LCP(l, i + 1);
        t2 = min(LCP(l + t + 1, i + 1 + t + 1), i - (l + t + 1));
        if (t + t2 + 1 == (i - l)) {
          if (s0[l2][j - 1]) {
            ch = s[l + t] - 'a';
            cw = i + 1 + t;
            if (pcnt - (s[i + 1 + t] == s[i]) + (s[l + t] == s[i]) <= 1)
              if (check(j - 1, i + 1, r, cw, ch)) {
                dd[ch][cw] += value(j + 1);
              }
          }
          if (s0[r2][j - 1]) {
            ch = s[i + 1 + t] - 'a';
            cw = l + t;
            if (pcnt - (s[l + t] == s[i]) + (s[i + 1 + t] == s[i]) <= 1)
              if (check(j - 1, l, i - 1, cw, ch)) {
                dd[ch][cw] += value(j + 1);
              }
          }
        }
      }
    }
  }
  go(1, 1, n, 0);
  cout << ans + delta << endl;
  scanf("\n");
  return 0;
}