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;
vector<string> split(const string& s, char c) {
  vector<string> v;
  stringstream ss(s);
  string x;
  while (getline(ss, x, c)) v.push_back(move(x));
  return move(v);
}
void err(vector<string>::iterator it) {}
template <typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
  cerr << it->substr((*it)[0] == ' ', it->length()) << " = " << a << '\n';
  err(++it, args...);
}
int N;
string ss;
int s[100013];
long long hsh[100013];
long long ppow[100013];
int ct[100013][26];
int A[100013];
long long B[100013];
long long total;
inline long long h(int i, int j) {
  return (1LL * 1000000007 * 1000000007 + hsh[j] - hsh[i] * ppow[j - i]) %
         1000000007;
}
inline int has(int i, int j, int c) { return ct[j][c] - ct[i][c]; }
long long dfs(int i, int part, long long phash, int z) {
  int half = (part + 1) / 2;
  if (i < 0 || i >= N || i < part || N - 1 - i < part) {
    return 0;
  }
  if (z == 0) {
    if (has(i - part, i, s[i])) {
      return 0;
    }
    if (h(i - part, i) != phash) {
      return 0;
    }
    if (A[i - half] < part) {
      return 0;
    }
  } else {
    if (has(i + 1, i + 1 + part, s[i])) {
      return 0;
    }
    if (h(i + 1, i + 1 + part) != phash) {
      return 0;
    }
    if (A[i + half] < part) {
      return 0;
    }
  }
  long long ret = 1LL * (2 * part + 1) * (2 * part + 1);
  long long phash2 =
      (phash + s[i] * ppow[part] + phash * ppow[part + 1]) % 1000000007;
  ret += dfs(i - part - 1, 2 * part + 1, phash2, 0);
  ret += dfs(i + part + 1, 2 * part + 1, phash2, 1);
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> ss;
  N = ss.size();
  for (int i = 0; i < N; i++) {
    s[i] = ss[i] - 'a';
  }
  ppow[0] = 1;
  for (int i = 0; i < N; i++) {
    hsh[i + 1] = (hsh[i] * 37) + s[i];
    hsh[i + 1] %= 1000000007;
    ppow[i + 1] = (ppow[i] * 37) % 1000000007;
  }
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < 26; j++) {
      ct[i + 1][j] = ct[i][j];
    }
    ct[i + 1][s[i]]++;
  }
  total = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0;; j++) {
      int part = (1 << j) - 1;
      int half = (part + 1) / 2;
      if (i < part || N - 1 - i < part) {
        break;
      }
      if (has(i - part, i + part + 1, s[i]) > 1) {
        break;
      }
      if (h(i - part, i) != h(i + 1, i + part + 1)) {
        break;
      }
      if (A[i - half] < part) {
        break;
      }
      A[i] = 2 * part + 1;
      total += (1LL * A[i] * A[i]);
      B[i - A[i] / 2] += (1LL * A[i] * A[i]);
      B[i + A[i] / 2 + 1] -= (1LL * A[i] * A[i]);
    }
  }
  for (int i = 1; i < N; i++) {
    B[i] += B[i - 1];
  }
  long long ans = total;
  for (int i = 0; i < N; i++) {
    for (int c = 0; c < 26; c++) {
      long long cur = total - B[i];
      int before = s[i];
      s[i] = c;
      for (int j = 0;; j++) {
        int part = (1 << j) - 1;
        long long result = dfs(i, part, h(i - part, i), 1);
        cur += result;
        if (!result) break;
      }
      s[i] = before;
      ans = max(ans, cur);
    }
  }
  cout << ans << endl;
  return 0;
}