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 int read() {
  int x = 0, f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  return x * f;
}
const int N = 100005;
char s[N];
int cnt[N][26], f[N][22];
long long tag[N], g[N][26];
unsigned long long h[N], mi[N];
unsigned long long geth(int l, int r) {
  return h[r] - h[l - 1] * mi[r - l + 1];
}
bool ext(int l, int r, int ch) { return cnt[r][ch] - cnt[l - 1][ch] > 0; }
void Cover(int l, int r, long long v) { tag[l] += v, tag[r + 1] -= v; }
int getpos(int l, int m, int r) {
  int L = 0, R = r - m, pos = 0;
  while (L <= R) {
    int mid = (L + R) >> 1;
    if (geth(l, l + mid - 1) == geth(m + 1, m + mid))
      pos = mid, L = mid + 1;
    else
      R = mid - 1;
  }
  pos++;
  if (m + pos == r || geth(l + pos, m - 1) == geth(m + pos + 1, r)) return pos;
  return -1;
}
int main() {
  scanf("%s", s + 1);
  int n = strlen(s + 1);
  for (int i = 1; i <= n; ++i) {
    s[i] -= 'a';
    for (int c = 0; c < 26; ++c) cnt[i][c] = cnt[i - 1][c];
    cnt[i][s[i]]++;
  }
  mi[0] = 1;
  long long sum = 0;
  for (int i = 1; i <= n; ++i) mi[i] = mi[i - 1] * 131;
  for (int i = 1; i <= n; ++i) h[i] = h[i - 1] * 131 + s[i];
  for (int i = 1; i <= n; ++i) f[i][0] = 1, sum++;
  for (int j = 1; j <= 17; ++j) {
    for (int i = 1; i <= n; ++i) {
      int d = (1 << j) - 1, l = i - d, r = i + d;
      if (l < 1 || r > n) continue;
      bool fl = f[i - (d + 1) / 2][j - 1], fr = f[i + (d + 1) / 2][j - 1],
           fm = geth(l, i - 1) == geth(i + 1, r);
      f[i][j] = fl && fr && fm && !ext(l, i - 1, s[i]);
      long long val = 1ll * (r - l + 1) * (r - l + 1);
      if (f[i][j]) {
        sum += val, Cover(l, i - 1, -val), Cover(i + 1, r, -val);
        for (int c = 0; c < 26; ++c)
          if (ext(l, i - 1, c)) g[i][c] -= val;
      } else {
        if (fl && fr && fm) {
          for (int c = 0; c < 26; ++c)
            if (!ext(l, i - 1, c)) g[i][c] += val;
        } else if (!fm) {
          int p = getpos(l, i, r);
          if (~p) {
            if (fl && !ext(l, i - 1, s[i])) g[i + p][s[l + p - 1]] += val;
            if (fr && !ext(i + 1, r, s[i])) g[l + p - 1][s[i + p]] += val;
          }
        }
      }
    }
  }
  long long ans = sum, now = 0;
  for (int i = 1; i <= n; ++i) {
    now += tag[i];
    for (int c = 0; c < 26; ++c)
      if (c != s[i]) ans = max(ans, sum + now + g[i][c]);
  }
  cout << ans;
  return 0;
}