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;
struct ii {
  int x, y;
  ii(int x = 0, int y = 0) : x(x), y(y) {}
  bool operator<(const ii &a) const {
    if (x != a.x) return x < a.x;
    return y < a.y;
  }
  bool operator==(const ii &a) const { return x == a.x && y == a.y; }
  ii friend operator+(ii a, ii b) { return ii(a.x + b.x, a.y + b.y); }
  ii friend operator-(ii a, ii b) { return ii(a.x - b.x, a.y - b.y); }
};
template <class T>
void sc(T &x) {
  x = 0;
  char c;
  int f = 1;
  while (c = getchar(), c < 48)
    if (c == '-') f = -1;
  do x = x * 10 + (c ^ 48);
  while (c = getchar(), c > 47);
  x *= f;
}
template <class T>
void nt(T x) {
  if (!x) return;
  nt(x / 10);
  putchar(x % 10 + '0');
}
template <class T>
void pt(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (!x)
    putchar('0');
  else
    nt(x);
}
template <class T>
void pts(T x) {
  pt(x);
  putchar(' ');
}
template <class T>
void ptn(T x) {
  pt(x);
  putchar('\n');
}
template <class v>
void pp(v x, int y) {
  static char ch[] = {" \n"};
  pt(x);
  putchar(ch[y]);
}
template <class T>
void PP(T *x, int y) {
  for (int i = 0, i_ = (y)-1; i <= i_; ++i) pp(x[i], i == y - 1);
}
template <class T>
void Max(T &x, T y) {
  if (x < y) x = y;
}
template <class T>
void Min(T &x, T y) {
  if (x > y) x = y;
}
const int maxn = 100005;
const unsigned long long H = 197;
int n, rad[maxn], sum[26][maxn];
long long ANS, ans, res[maxn];
unsigned long long hs[maxn], hp[maxn];
char s[maxn];
unsigned long long Str(int l, int r) {
  return hs[r] - hs[l - 1] * hp[r - l + 1];
}
int Cnt(int l, int r, int c) { return sum[c][r] - sum[c][l - 1]; }
void dfs(int l, int r, unsigned long long v) {
  int k = r - l + 1, x;
  ans += 1ll * k * k;
  x = l - 1;
  if (x - k >= 1 && Cnt(x - k, x - 1, s[x]) == 0 && Str(x - k, x - 1) == v)
    dfs(x - k, r, (v * H + s[x]) * hp[k] + v);
  x = r + 1;
  if (x + k <= n && Cnt(x + 1, x + k, s[x]) == 0 && Str(x + 1, x + k) == v)
    dfs(l, x + k, (v * H + s[x]) * hp[k] + v);
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1, i_ = (n + 1) - 1; i <= i_; ++i) s[i] -= 'a';
  hp[0] = 1;
  for (int i = 1, i_ = (n + 1) - 1; i <= i_; ++i) {
    hs[i] = hs[i - 1] * H + s[i];
    hp[i] = hp[i - 1] * H;
  }
  for (int j = 0, j_ = (26) - 1; j <= j_; ++j)
    for (int i = 1, i_ = (n + 1) - 1; i <= i_; ++i) {
      sum[j][i] += sum[j][i - 1] + (s[i] == j);
    }
  for (int i = 1, i_ = (n + 1) - 1; i <= i_; ++i) rad[i] = 1;
  for (int k = 3; k <= n; k = k << 1 | 1) {
    int t = k >> 1;
    for (int i = 1, i_ = (n + 1) - 1; i <= i_; ++i)
      if (i - t >= 1 && i + t <= n) {
        if (rad[i - t / 2 - 1] >= t && rad[i + t / 2 + 1] >= t &&
            Cnt(i - t, i + t, s[i]) == 1 &&
            Str(i - t, i - 1) == Str(i + 1, i + t)) {
          rad[i] = k;
          ANS += 1ll * k * k;
          res[i - t] += 1ll * k * k;
          res[i + t + 1] -= 1ll * k * k;
        }
      }
  }
  for (int i = 1, i_ = (n + 1) - 1; i <= i_; ++i) res[i] += res[i - 1];
  long long mx = ANS;
  for (int i = 1, i_ = (n + 1) - 1; i <= i_; ++i) {
    for (int j = 0, j_ = (26) - 1; j <= j_; ++j) {
      ans = ANS - res[i] - 1;
      dfs(i, i, j);
      for (int k = 3; k <= n; k = k << 1 | 1) {
        int t = k >> 1;
        if (i - t >= 1 && i + t <= n && rad[i - t / 2 - 1] >= t &&
            rad[i + t / 2 + 1] >= t &&
            Cnt(i - t, i - 1, j) + Cnt(i + 1, i + t, j) == 0 &&
            Str(i - t, i - 1) == Str(i + 1, i + t))
          dfs(i - t, i + t,
              (Str(i - t, i - 1) * H + j) * hp[t] + Str(i + 1, i + t));
        else
          break;
      }
      Max(mx, ans);
    }
  }
  ptn(n + mx);
  return 0;
}