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;
template <typename T>
inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
const int oo = 0x3f3f3f3f;
const int maxn = 100000, max0 = 17;
bool ok[max0][maxn + 5];
int n;
char s[maxn + 5];
bool check(int i, int j, int l, char c) {
  int now = (1 << l) - 1;
  while (1) {
    if (s[i + now] != s[j + now] || s[i + now] == c) return 0;
    if (!now) break;
    (now >>= 1);
  }
  return 1;
}
bool is_ok(int l, int i) {
  if (!l) return 1;
  if (i + (1 << l) >= n) return 0;
  if (!ok[l - 1][i] || !ok[l - 1][i + (1 << l)]) return 0;
  return check(i, i + (1 << l), l - 1, s[i + (1 << l) - 1]);
}
long long sum[maxn + 5];
long long tmp_sum[maxn + 5];
int go(int i, int j, int l) {
  if (l < 0) return 0;
  int mid = l + (1 << (j + 1)) - 1;
  int r = mid + 1;
  if (r + (1 << (j + 1)) - 1 > n) return 0;
  int now = (1 << j) - 1;
  int can = (1 << 26) - 1;
  while (1) {
    char a = s[l + now], b = s[r + now];
    if (l + now == i) can &= (1 << (s[r + now] - 'a')), a = b;
    if (mid == i) {
      can &= ((1 << 26) - 1) ^ (1 << (s[l + now] - 'a'));
    } else if (s[mid] == a)
      can = 0;
    if (r + now == i) can &= (1 << (s[l + now] - 'a')), b = a;
    if (a != b) can = 0;
    if (!can) break;
    if (!now) break;
    now >>= 1;
  }
  return can;
}
int main() {
  scanf("%s", s);
  n = strlen(s);
  for (int i = (0), _end_ = (n); i < _end_; ++i) ok[0][i] = 1;
  long long now = 0;
  for (int i = (1), _end_ = (max0); i < _end_; ++i)
    for (int j = (0), _end_ = (n); j < _end_; ++j) ok[i][j] = is_ok(i, j);
  for (int i = (0), _end_ = (max0); i < _end_; ++i) {
    long long tmp = (1 << (i + 1)) - 1;
    memset(tmp_sum, 0, sizeof tmp_sum);
    for (int j = (0), _end_ = (n - tmp + 1); j < _end_; ++j)
      if (ok[i][j]) {
        tmp_sum[j] += tmp * tmp;
        tmp_sum[j + tmp] -= tmp * tmp;
        now += tmp * tmp;
      }
    for (int j = (0), _end_ = (n); j < _end_; ++j)
      sum[j] += tmp_sum[j], tmp_sum[j + 1] += tmp_sum[j];
  }
  long long ans = now;
  for (int i = (0), _end_ = (n); i < _end_; ++i) {
    static long long add[26];
    memset(add, 0, sizeof add);
    vector<pair<int, int> > all, all0;
    all.push_back(make_pair(i, (1 << 26) - 1));
    for (int j = (1), _end_ = (max0); j < _end_; ++j) {
      all0.clear();
      long long tmp = (1 << j) - 1;
      for (auto first : all) {
        for (int k = (0), _end_ = (26); k < _end_; ++k)
          if (first.second >> k & 1) add[k] += tmp * tmp;
        for (int k = (0), _end_ = (2); k < _end_; ++k) {
          int l = 0;
          if (!k) {
            l = first.first - (1 << j);
            if (!ok[j - 1][l]) continue;
          } else {
            l = first.first;
            if (!ok[j - 1][l + (1 << j)]) continue;
          }
          int can = first.second & go(i, j - 1, l);
          if (can) all0.push_back(make_pair(l, can));
        }
      }
      if (i - (1 << j) + 1 >= 0 && ok[j - 1][i + 1] &&
          ok[j - 1][i - (1 << j) + 1] &&
          check(i - (1 << j) + 1, i + 1, j - 1, '@')) {
        int tmp = go(i, j - 1, i - (1 << j) + 1);
        if (tmp) all0.push_back(make_pair(i - (1 << j) + 1, tmp));
      }
      all = all0;
    }
    for (int j = (0), _end_ = (26); j < _end_; ++j)
      chkmax(ans, now - sum[i] + add[j]);
  }
  printf("%I64d\n", ans);
  return 0;
}