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;
inline long long read() {
  long long x = 0;
  char ch = getchar();
  bool f = 0;
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = 1;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return f ? -x : x;
}
void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) write(x / 10);
  putchar(x % 10 + '0');
}
void writeln(long long x) {
  write(x);
  puts("");
}
void writep(long long x) {
  write(x);
  putchar(' ');
}
const int N = 1e5 + 5;
int n, sum[N][26];
long long ans, f[N], g[N][26];
char s[N];
bool used[N][20];
namespace ycl {
const unsigned long long base = 233;
unsigned long long bin[N], sum[N];
unsigned long long find(int l, int r) {
  return sum[r] - sum[l - 1] * bin[r - l + 1];
}
void init() {
  bin[0] = 1;
  for (int i = (int)(1); i <= (int)(n); i++) bin[i] = bin[i - 1] * base;
  for (int i = (int)(1); i <= (int)(n); i++)
    sum[i] = sum[i - 1] * base + (unsigned long long)s[i];
}
}  // namespace ycl
void getf() {
  for (int o = (int)(1); o <= (int)(n); o++)
    for (int i = (int)(1); i <= (int)(18); i++) {
      int len = (1 << i) - 1;
      int l = o, r = o + len - 1, mid = l + r >> 1;
      if (r > n) break;
      if (len == 1) {
        used[l][i] = 1;
        ans++;
        f[l]++;
        f[r + 1]--;
        continue;
      }
      if (ycl::find(l, mid - 1) == ycl::find(mid + 1, r)) {
        if (sum[r][s[mid] - 'a'] - sum[l - 1][s[mid] - 'a'] == 1) {
          f[l] += (long long)len * len;
          f[r + 1] -= (long long)len * len;
          ans += (long long)len * len;
          used[l][i] = 1;
        } else
          break;
      } else
        break;
    }
  for (int i = (int)(1); i <= (int)(n); i++) f[i] += f[i - 1];
}
int lcp(int x, int y) {
  int res = 0;
  for (int i = (int)(18); i >= (int)(0); i--) {
    int len = res + (1 << i) - 1;
    if (x + len > n || y + len > n) continue;
    if (ycl::find(x + res, x + len) == ycl::find(y + res, y + len))
      res += (1 << i);
  }
  return res;
}
void solve(int l, int k, int len) {
  int r = l + len - 1, mid = l + r >> 1;
  if (r > n) return;
  if (len == 1) {
    for (int i = (int)(0); i <= (int)(25); i++) {
      if (i == (int)(s[l] - 'a')) continue;
      g[l][i]++;
    }
    return;
  }
  if (ycl::find(l, mid - 1) == ycl::find(mid + 1, r)) {
    if (used[l][k - 1] && used[mid + 1][k - 1]) {
      for (int i = (int)(0); i <= (int)(25); i++) {
        if (i == (int)(s[mid] - 'a')) continue;
        if (sum[r][i] - sum[l - 1][i] == 0) g[mid][i] += (long long)len * len;
      }
    }
  }
  int l1 = l, l2 = mid + 1, t = lcp(l1, l2);
  if (t >= (len >> 1)) return;
  if (l1 + t + 1 + lcp(l1 + t + 1, l2 + t + 1) < mid) return;
  int pos1 = l1 + t, pos2 = l2 + t;
  if (used[l2][k - 1] && sum[r][s[mid] - 'a'] - sum[mid][s[mid] - 'a'] == 0)
    g[pos1][s[pos2] - 'a'] += (long long)len * len;
  if (used[l1][k - 1] &&
      sum[mid - 1][s[mid] - 'a'] - sum[l - 1][s[mid] - 'a'] == 0)
    g[pos2][s[pos1] - 'a'] += (long long)len * len;
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  ycl::init();
  for (int i = (int)(1); i <= (int)(n); i++) {
    for (int o = (int)(0); o <= (int)(25); o++) sum[i][o] = sum[i - 1][o];
    sum[i][s[i] - 'a']++;
  }
  getf();
  for (int i = (int)(1); i <= (int)(n); i++)
    for (int j = (int)(1); j <= (int)(18); j++) solve(i, j, (1 << j) - 1);
  long long mx = 0;
  for (int i = (int)(1); i <= (int)(n); i++)
    for (int j = (int)(0); j <= (int)(25); j++) {
      if (j == (int)(s[i] - 'a')) continue;
      mx = max(mx, g[i][j] - f[i]);
    }
  cout << ans + mx;
}