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 <class T>
void debug(T a, T b) {
  ;
}
template <class T>
void chmin(T& a, const T& b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T& a, const T& b) {
  if (a < b) a = b;
}
namespace std {
template <class S, class T>
ostream& operator<<(ostream& out, const pair<S, T>& a) {
  out << '(' << a.first << ',' << a.second << ')';
  return out;
}
}  // namespace std
long long int readL() {
  long long int res;
  scanf("%I64d", &res);
  return res;
}
void printL(long long int res) { printf("%I64d", res); }
struct Hash {
  static const int MAX_N = 300005;
  static Hash pows[MAX_N];
  static long long int M1;
  static long long int mul1[MAX_N];
  long long int a;
  static void init() {
    M1 = 100000037;
    mul1[0] = 1;
    for (int i = 0; i < (MAX_N - 1); ++i) {
      mul1[i + 1] = mul1[i] * M1;
    }
    for (int i = 0; i < (MAX_N); ++i) pows[i].a = mul1[i];
  }
  Hash(long long int val = 0) { a = val; }
  Hash& operator+=(const Hash& b) {
    a += b.a;
    return *this;
  }
  Hash& operator-=(const Hash& b) {
    a -= b.a;
    return *this;
  }
  Hash& operator<<=(int k) {
    a *= mul1[k];
    return *this;
  }
  Hash& operator=(Hash b) {
    a = b.a;
    return *this;
  }
  Hash operator-() const { return Hash(0) -= Hash(*this); }
  Hash operator+(const Hash& b) const { return Hash(*this) += b; }
  Hash operator-(const Hash& b) const { return Hash(*this) -= b; }
  Hash operator<<(int k) const { return Hash(*this) <<= k; }
  bool operator==(const Hash& b) const { return (a == b.a); }
  bool operator!=(const Hash& b) const { return (a != b.a); }
};
const int Hash::MAX_N;
long long int Hash::M1;
long long int Hash::mul1[MAX_N];
Hash Hash::pows[MAX_N];
int rad[16];
bool gray[16][100005];
char s[100005];
int n;
int app[100005][26];
long long int cost[100005];
long long int prof[100005][26];
Hash sum[100005];
bool same(int a, int b, int len) {
  if (a + len > n || b + len > n) return false;
  return (sum[a + len] - (sum[a] << len)) == (sum[b + len] - (sum[b] << len));
}
int clen(int a, int b) {
  int res = 0;
  for (int i = 15; i >= 0; --i)
    if (same(a, b, 1 << i)) {
      a += (1 << i);
      b += (1 << i);
      res += (1 << i);
    }
  return res;
}
int main() {
  Hash::init();
  scanf("%s", s);
  n = strlen(s);
  for (int i = 0; i < (n); ++i) sum[i + 1] = (sum[i] << 1) + Hash(s[i]);
  for (int i = 0; i < (n); ++i) gray[0][i] = true;
  for (int i = 0; i < (n); ++i) {
    for (int j = 0; j < (26); ++j) app[i + 1][j] = app[i][j];
    ++app[i + 1][s[i] - 'a'];
  }
  rad[0] = 0;
  long long int base = 0;
  for (int j = 1; j < 16; ++j) {
    rad[j] = rad[j - 1] * 2 + 1;
    for (int i = 0; i < (n); ++i) {
      int r_c = i + (rad[j] + 1) / 2, l_c = i - (rad[j] + 1) / 2;
      if (r_c >= n || l_c < 0) continue;
      int col = s[i] - 'a';
      if (gray[j - 1][r_c] && gray[j - 1][l_c] &&
          same(r_c, l_c, rad[j - 1] + 1) &&
          app[i + rad[j] + 1][col] - app[i - rad[j]][col] == 1) {
        gray[j][i] = true;
      }
    }
  }
  for (int j = 0; j < (16); ++j)
    for (int i = 0; i < (n); ++i)
      if (gray[j][i]) {
        int L = i - rad[j], R = i + rad[j] + 1;
        long long int len = rad[j] * 2 + 1;
        cost[L] += len * len;
        cost[R] -= len * len;
        base += len * len;
      }
  for (int i = 0; i < (n); ++i) cost[i + 1] += cost[i];
  for (int j = 0; j < (16); ++j)
    for (int i = 0; i < (n); ++i) {
      if (j == 0) {
        for (int c = 0; c < (26); ++c) ++prof[i][c];
      } else {
        int L = i - rad[j], R = i + rad[j] + 1;
        int r_c = i + (rad[j] + 1) / 2, l_c = i - (rad[j] + 1) / 2;
        if (r_c >= n || l_c < 0) continue;
        int col = s[i] - 'a';
        long long int len = (rad[j] * 2 + 1);
        if (gray[j - 1][r_c] && gray[j - 1][l_c] &&
            same(r_c, l_c, rad[j - 1] + 1)) {
          for (int c = 0; c < (26); ++c)
            if (app[R][c] - app[L][c] - (s[i] == 'a' + c ? 1 : 0) == 0) {
              prof[i][c] += len * len;
            }
        }
        if (!gray[j - 1][l_c] && !gray[j - 1][r_c]) continue;
        int indx = clen(L, i + 1);
        int pos = indx + L;
        if (pos >= i) continue;
        if (clen(pos + 1, i + 1 + indx + 1) + pos + 1 < i) continue;
        if (gray[j - 1][l_c] && app[i][col] - app[L][col] == 0)
          prof[indx + i + 1][s[pos] - 'a'] += len * len;
        if (gray[j - 1][r_c] && app[R][col] - app[i + 1][col] == 0)
          prof[pos][s[indx + i + 1] - 'a'] += len * len;
      }
    }
  long long int res = base;
  ;
  ;
  for (int i = 0; i < (n); ++i)
    for (int c = 0; c < (26); ++c)
      if (s[i] - 'a' != c) chmax(res, base + prof[i][c] - cost[i]);
  cout << res << endl;
  return 0;
}