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 N(100010), L(17), P(53);
int n;
long long sc[N][26];
int glen[L + 1];
bool gray[L + 1][N];
int cnt[N][26];
long long cut[N];
long long ha[N], p[N];
char s[N];
bool same(int x, int y, int len) {
  if (x > y) swap(x, y);
  long long h1 = ha[x + len - 1] - ha[x - 1], h2 = ha[y + len - 1] - ha[y - 1];
  return h1 * p[y - x] == h2;
}
int lcp(int x, int y) {
  int ret = 0;
  for (int i = L; i != -1; --i)
    if (x + (1 << i) - 1 <= n && y + (1 << i) - 1 <= n && same(x, y, 1 << i)) {
      x += 1 << i;
      y += 1 << i;
      ret += 1 << i;
    }
  return ret;
}
int lcs(int x, int y) {
  int ret = 0;
  for (int i = L; i != -1; --i)
    if (x - (1 << i) + 1 > 0 && y - (1 << i) + 1 > 0 &&
        same(x - (1 << i) + 1, y - (1 << i) + 1, 1 << i)) {
      x -= 1 << i;
      y -= 1 << i;
      ret += 1 << i;
    }
  return ret;
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  p[0] = 1;
  for (int i = 1; i <= n; ++i) {
    p[i] = p[i - 1] * P;
    ha[i] = ha[i - 1] + p[i] * (s[i] - 'a' + 1);
    memcpy(cnt[i], cnt[i - 1], sizeof(cnt[i - 1]));
    ++cnt[i][s[i] - 'a'];
    gray[1][i] = true;
  }
  for (int i = 1; i <= L; ++i) glen[i] = glen[i - 1] * 2 + 1;
  long long ans = n;
  for (int i = 2; i <= L; ++i) {
    for (int j = 1; j + glen[i] - 1 <= n; ++j) {
      int l = j, mid = j + glen[i - 1], r = j + glen[i] - 1, c = s[mid] - 'a';
      gray[i][j] = gray[i - 1][l] && gray[i - 1][mid + 1] &&
                   cnt[r][c] - cnt[l - 1][c] == 1 &&
                   same(l, mid + 1, glen[i - 1]);
      if (gray[i][j]) {
        long long tmp = (long long)glen[i] * glen[i];
        ans += tmp;
        cut[l] += tmp;
        cut[r + 1] -= tmp;
      }
    }
  }
  ++cut[0];
  for (int i = 1; i <= n; ++i) cut[i] += cut[i - 1];
  for (int i = 1; i <= L; ++i) {
    if (i == 1) {
      for (int j = int(1); j < int(n + 1); ++j)
        for (int k = int(0); k < int(26); ++k) ++sc[j][k];
      continue;
    }
    for (int j = glen[i - 1] + 1; j + glen[i - 1] <= n; ++j) {
      int l = j - glen[i - 1], mid = j, r = j + glen[i - 1];
      if (gray[i - 1][l] && gray[i - 1][mid + 1] &&
          same(l, mid + 1, glen[i - 1])) {
        for (int k = 0; k != 26; ++k)
          if (cnt[r][k] - cnt[l - 1][k] == 0)
            sc[j][k] += (long long)glen[i] * glen[i];
      }
      int len1 = lcp(l, mid + 1), len2 = lcs(mid - 1, r), c = s[mid] - 'a';
      if (len1 + len2 == glen[i - 1] - 1 && gray[i - 1][mid + 1]) {
        int p = l + len1, q = s[mid + 1 + len1] - 'a';
        if (cnt[r][c] - cnt[l - 1][c] == 1 + (c == s[p] - 'a'))
          sc[p][q] += (long long)glen[i] * glen[i];
      }
      if (len1 + len2 == glen[i - 1] - 1 && gray[i - 1][l]) {
        int p = mid + 1 + len1, q = s[l + len1] - 'a';
        if (cnt[r][c] - cnt[l - 1][c] == 1 + (c == s[p] - 'a'))
          sc[p][q] += (long long)glen[i] * glen[i];
      }
    }
  }
  long long del = 0;
  for (int i = 1; i <= n; ++i)
    for (int j = 0; j != 26; ++j)
      if (s[i] != j + 'a') del = max(del, sc[i][j] - cut[i]);
  cout << ans + del << endl;
  return 0;
}