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 N = 1e5 + 8, Base = 12345;
int n, Pre[N][26], Suf[N][26];
bool f[22][N];
char s[N];
long long ans0, ans, gain[N][26], pE[N];
inline void cover(int l, int r, long long d) {
  pE[l] += d;
  pE[r + 1] -= d;
}
struct Hash {
  int mod, h[N], b[N];
  void init() {
    b[0] = 1;
    for (int i = 1; i <= n; i++)
      b[i] = (long long)b[i - 1] * Base % mod,
      h[i] = ((long long)h[i - 1] * Base % mod + s[i]) % mod;
  }
  int query(int l, int r) {
    int ret = h[r] - (long long)h[l - 1] * b[r - l + 1] % mod;
    return ret >= 0 ? ret : ret + mod;
  }
} A, B;
void init() {
  A.mod = 19960403, B.mod = 19970413;
  A.init();
  B.init();
  for (int i = 1; i <= n; i++) f[1][i] = 1, ans0++;
  for (int j = 0; j <= 25; j++) Pre[0][j] = 0, Suf[n + 1][j] = n + 1;
  for (int i = 1; i <= n; i++)
    for (int j = 0; j <= 25; j++)
      Pre[i][j] = s[i - 1] == j + 'a' ? i - 1 : Pre[i - 1][j];
  for (int i = n; i >= 1; i--)
    for (int j = 0; j <= 25; j++)
      Suf[i][j] = s[i + 1] == j + 'a' ? i + 1 : Suf[i + 1][j];
}
bool Equal(int l1, int r1, int l2, int r2) {
  if (l1 > r1 && l2 > r2) return 1;
  if (A.query(l1, r1) == A.query(l2, r2))
    if (B.query(l1, r1) == B.query(l2, r2)) return 1;
  return 0;
}
void solve() {
  for (int k = 2; (1 << k) - 1 <= n; k++)
    for (int i = 1; i <= n; i++) {
      int l = i - ((1 << k) - 1) / 2, r = i + ((1 << k) - 1) / 2;
      if (l < 1 || r > n) continue;
      long long w = (long long)(r - l + 1) * (r - l + 1);
      int lp = (l + i - 1) >> 1, rp = (i + 1 + r) >> 1;
      if (f[k - 1][lp] && f[k - 1][rp] && Equal(l, i - 1, i + 1, r)) {
        if (Pre[i][s[i] - 'a'] < l && Suf[i][s[i] - 'a'] > r) {
          cover(l, i - 1, -w), cover(i + 1, r, -w), f[k][i] = 1, ans0 += w;
        }
        for (int j = 0; j <= 25; j++)
          if (j + 'a' != s[i]) {
            if (!f[k][i] && Pre[i][j] < l && Suf[i][j] > r) gain[i][j] += w;
            if (f[k][i] && !(Pre[i][j] < l && Suf[i][j] > r)) gain[i][j] -= w;
          }
      }
      if ((f[k - 1][lp] || f[k - 1][rp]) && !Equal(l, i - 1, i + 1, r)) {
        int bot = l, top = i - 1, p = 0;
        while (bot <= top) {
          int mid = bot + top >> 1;
          if (Equal(l, mid, i + 1, i + 1 + mid - l))
            bot = mid + 1;
          else
            p = mid, top = mid - 1;
        }
        if (Equal(p + 1, i - 1, r - (i - 1 - p - 1), r)) {
          char c = s[p + (1 << k >> 1)];
          if (f[k - 1][rp] && s[i] != c && Suf[i][s[i] - 'a'] > r &&
              (Pre[i][s[i] - 'a'] < l ||
               (Pre[i][s[i] - 'a'] == p && Pre[p][s[i] - 'a'] < l)))
            gain[p][c - 'a'] += w;
          c = s[p];
          p += (1 << k >> 1);
          if (f[k - 1][lp] && s[i] != c && Pre[i][s[i] - 'a'] < l &&
              (Suf[i][s[i] - 'a'] > r ||
               (Suf[i][s[i] - 'a'] == p && Suf[p][s[i] - 'a'] > r)))
            gain[p][c - 'a'] += w;
        }
      }
    }
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  init();
  solve();
  long long cur = 0;
  ans = ans0;
  for (int i = 1; i <= n; i++) {
    cur += pE[i];
    for (int j = 0; j <= 25; j++)
      if (j + 'a' != s[i]) {
        ans = max(ans, ans0 + cur + gain[i][j]);
      }
  }
  cout << ans << endl;
  return 0;
}