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 + 5;
const long long base = 137;
const long long mod = 1e9 + 7;
string s;
bool ok[maxn][20];
int n, H[maxn], cnt[maxn][30], power[maxn];
long long score[maxn][30], d[maxn], a[maxn];
int Get(char c, int low, int high) {
  return cnt[high][c - 'a'] - cnt[low - 1][c - 'a'];
}
int getHash(int l, int r) {
  if (l == 0) return H[r];
  return (H[r] - H[l - 1] * (long long)power[r - l + 1] +
          mod * (long long)mod) %
         mod;
}
void Prepare() {
  cin >> s;
  n = (int)s.size();
  s = ' ' + s;
  memset(cnt, 0, sizeof(cnt));
  for (int i = 1; i <= n; i++) {
    for (int j = 'a' - 'a'; j <= 'z' - 'a'; j++) cnt[i][j] = cnt[i - 1][j];
    cnt[i][s[i] - 'a']++;
  }
  power[0] = 1;
  for (int i = 1; i <= n; i++) power[i] = (power[i - 1] * base) % mod;
  H[1] = s[1];
  for (int i = 2; i <= n; i++) H[i] = (H[i - 1] * (long long)base + s[i]) % mod;
  memset(ok, false, sizeof(ok));
  for (int i = 1; i <= n; i++) ok[i][1] = true;
  for (int j = 2; (1 << j) - 1 <= n; j++)
    for (int i = 1; i + (1 << j) - 2 <= n; i++) {
      if (Get(s[i + (1 << (j - 1)) - 1], i, i + (1 << j) - 2) == 1 &&
          ok[i][j - 1] && ok[i + (1 << (j - 1))][j - 1] &&
          getHash(i, i + (1 << (j - 1)) - 2) ==
              getHash(i + (1 << (j - 1)), i + (1 << j) - 2))
        ok[i][j] = true;
      else
        ok[i][j] = false;
    }
}
int FirstDiff(int i, int j, int x, int y) {
  int low = 0, high = j - i, res = high + 1;
  while (low <= high) {
    int mid = (low + high) / 2;
    if (getHash(i, i + mid) != getHash(x, x + mid))
      res = min(res, mid), high = mid - 1;
    else
      low = mid + 1;
  }
  if (res == j - i + 1) return -1;
  if (i + res + 1 <= j) {
    if (getHash(i + res + 1, j) != getHash(x + res + 1, y)) return -1;
  }
  return res;
}
void Process(int low, int high, int sz) {
  long long delta = (high - low + 1) * ((long long)high - low + 1);
  if (ok[low][sz]) {
    a[low] += delta;
    a[high + 1] -= delta;
    d[1] += delta;
    d[low] -= delta;
    d[high + 1] += delta;
    d[n + 1] -= delta;
  }
  int mid = (high + low) / 2;
  if (ok[low][sz - 1] && ok[low + (1 << (sz - 1))][sz - 1] &&
      getHash(low, low + (1 << (sz - 1)) - 2) ==
          getHash(low + (1 << (sz - 1)), low + (1 << sz) - 2)) {
    for (int i = 'a' - 'a'; i <= 'z' - 'a'; i++)
      if (i != s[mid] - 'a' &&
          Get(char(i + 'a'), low, high) - ((int)s[mid] - 'a' == i) == 0)
        score[mid][i] += delta;
  }
  int p =
      FirstDiff(low, low + (1 << (sz - 1)) - 2, low + (1 << (sz - 1)), high);
  if (ok[low][sz - 1] && Get(s[mid], low, low + (1 << (sz - 1)) - 2) == 0) {
    if (p != -1) score[low + (1 << (sz - 1)) + p][s[low + p] - 'a'] += delta;
  }
  if (ok[low + (1 << (sz - 1))][sz - 1] &&
      Get(s[mid], low + (1 << (sz - 1)), high) == 0) {
    if (p != -1) score[low + p][s[low + (1 << (sz - 1)) + p] - 'a'] += delta;
  }
}
void Solve() {
  memset(score, 0, sizeof(score));
  for (int i = 1; i <= n; i++)
    for (int j = 2; i + (1 << j) - 2 <= n; j++) Process(i, i + (1 << j) - 2, j);
  d[0] = a[0] = 0;
  for (int i = 1; i <= n; i++) d[i] += d[i - 1], a[i] += a[i - 1];
  for (int i = 1; i <= n; i++) {
    for (int j = 'a' - 'a'; j <= 'z' - 'a'; j++) score[i][j] += d[i];
    score[i][s[i] - 'a'] += a[i];
  }
  long long res = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 'a' - 'a'; j <= 'z' - 'a'; j++)
      res = max(res, score[i][j] + n);
  cout << res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  Prepare();
  Solve();
}