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>
#pragma comment(linker, "/STACK:64000000")
using namespace std;
string s;
char buf[100500];
int l[100500][26];
long long ans, initVal;
int size[30];
long long st[100500];
long long hsh[100500];
int prv[100500][26], nxt[100500][26];
int near[26];
long long inc[100500][26];
long long decc[100500];
long long f[30];
long long mul(long long a, long long b) {
  long long q = ((long double)a * (long double)b) /
                (long double)((long long)(1e18) + 3LL);
  long long res = a * b - q * ((long long)(1e18) + 3LL);
  while (res < 0) {
    res += ((long long)(1e18) + 3LL);
  }
  while (res >= ((long long)(1e18) + 3LL)) {
    res -= ((long long)(1e18) + 3LL);
  }
  return res;
}
void initHash() {
  st[0] = 1LL;
  for (int j = 1; j <= 100000; j++) {
    st[j] = mul(st[j - 1], 1009);
  }
}
long long getHash(long long hsh[], int l, int r) {
  if (l > r) {
    return 0LL;
  }
  long long res =
      (hsh[r + 1] - mul(hsh[l], st[r - l + 1]) + ((long long)(1e18) + 3LL)) %
      ((long long)(1e18) + 3LL);
  return res;
}
void buildHash(string &s, long long hsh[]) {
  for (int j = 0; j < s.size(); j++) {
    hsh[j + 1] = (mul(hsh[j], 1009) + s[j]) % ((long long)(1e18) + 3LL);
  }
}
void findNearestSymbols() {
  for (int j = 0; j < 26; j++) {
    near[j] = -1;
  }
  for (int j = 0; j < s.size(); j++) {
    memcpy(prv[j], near, sizeof(near));
    near[s[j] - 'a'] = j;
  }
  for (int j = 0; j < 26; j++) {
    near[j] = s.size();
  }
  for (int j = s.size() - 1; j >= 0; j--) {
    memcpy(nxt[j], near, sizeof(near));
    near[s[j] - 'a'] = j;
  }
}
void init() {
  scanf("%s", &buf);
  s = string(buf);
}
void solve() {
  init();
  initHash();
  buildHash(s, hsh);
  findNearestSymbols();
  size[1] = f[1] = 1;
  for (int j = 2;; j++) {
    size[j] = (size[j - 1] << 1) + 1;
    f[j] = f[j - 1] + (long long)(size[j]) * (long long)(size[j]);
    if (size[j] > s.size()) {
      break;
    }
  }
  for (int j = 0; j < s.size(); j++) {
    for (int i = 0; i < 26; i++) {
      l[j][i] = 1;
    }
  }
  for (int h = 2; size[h] <= s.size(); h++) {
    for (int j = size[h - 1]; j + size[h - 1] < s.size(); j++) {
      for (int sym = 0; sym < 26; sym++) {
        if (l[j][sym] < h - 1) {
          continue;
        }
        if (l[j + size[h - 2] + 1][s[j + size[h - 2] + 1] - 'a'] >= h - 1 &&
            l[j - size[h - 2] - 1][s[j - size[h - 2] - 1] - 'a'] >= h - 1 &&
            nxt[j][sym] > j + size[h - 1] && prv[j][sym] < j - size[h - 1] &&
            getHash(hsh, j - size[h - 1], j - 1) ==
                getHash(hsh, j + 1, j + size[h - 1])) {
          l[j][sym]++;
        }
      }
    }
  }
  for (int j = 0; j < s.size(); j++) {
    for (int h = 1; h <= l[j][s[j] - 'a']; h++) {
      decc[j - size[h - 1]] += (long long)(size[h]) * (long long)(size[h]);
      decc[j] -= (long long)(size[h]) * (long long)(size[h]);
      decc[j + 1] += (long long)(size[h]) * (long long)(size[h]);
      decc[j + size[h - 1] + 1] -= (long long)(size[h]) * (long long)(size[h]);
    }
    initVal += f[l[j][s[j] - 'a']];
  }
  for (int j = 0; j < s.size(); j++) {
    for (int h = l[j][s[j] - 'a'] + 1;; h++) {
      if (j - size[h - 1] < 0 || j + size[h - 1] >= s.size()) {
        break;
      }
      if (l[j + size[h - 2] + 1][s[j + size[h - 2] + 1] - 'a'] < h - 1 &&
          l[j - size[h - 2] - 1][s[j - size[h - 2] - 1] - 'a'] < h - 1) {
        break;
      }
      if (getHash(hsh, j - size[h - 1], j - 1) ==
          getHash(hsh, j + 1, j + size[h - 1])) {
        continue;
      }
      int q1, q2;
      int lft = 0, rght = size[h - 1] - 1;
      while (lft <= rght) {
        int mid = (lft + rght) >> 1;
        if (getHash(hsh, j - size[h - 1], j - size[h - 1] + mid) ==
            getHash(hsh, j + 1, j + 1 + mid)) {
          lft = mid + 1;
        } else {
          q1 = mid;
          rght = mid - 1;
        }
      }
      lft = 0, rght = size[h - 1] - 1;
      while (lft <= rght) {
        int mid = (lft + rght) >> 1;
        if (getHash(hsh, j - size[h - 1] + mid, j - 1) ==
            getHash(hsh, j + 1 + mid, j + size[h - 1])) {
          rght = mid - 1;
        } else {
          q2 = mid;
          lft = mid + 1;
        }
      }
      if (q1 != q2) {
        break;
      }
      if (l[j - size[h - 2] - 1][s[j - size[h - 2] - 1] - 'a'] >= h - 1 &&
          prv[j][s[j] - 'a'] < j - size[h - 1]) {
        inc[j + 1 + q1][s[j - size[h - 1] + q1] - 'a'] +=
            (long long)(size[h]) * (long long)(size[h]);
      }
      if (l[j + size[h - 2] + 1][s[j + size[h - 2] + 1] - 'a'] >= h - 1 &&
          nxt[j][s[j] - 'a'] > j + size[h - 1]) {
        inc[j - size[h - 1] + q1][s[j + 1 + q1] - 'a'] +=
            (long long)(size[h]) * (long long)(size[h]);
      }
    }
  }
  for (int j = 1; j < s.size(); j++) {
    decc[j] += decc[j - 1];
  }
  ans = initVal;
  for (int j = 0; j < s.size(); j++) {
    for (int i = 0; i < 26; i++) {
      long long delta = f[l[j][i]] - f[l[j][s[j] - 'a']] + inc[j][i] - decc[j];
      ans = max(initVal + delta, ans);
    }
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}