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 maxn = 1e5 + 7;
long long c[maxn], h[maxn][26], res, ans;
bool vc[20][maxn];
int n;
char s[maxn];
struct Hush {
  static const int base = 1331;
  unsigned long long hsh[maxn], pw[maxn];
  inline void build() {
    pw[0] = 1;
    for (int i = 1; i <= n; ++i)
      hsh[i] = hsh[i - 1] * base + (s[i] -= 'a'), pw[i] = pw[i - 1] * base;
    return;
  }
  inline unsigned long long query(int l, int r) {
    return hsh[r] - hsh[l - 1] * pw[r - l + 1];
  }
  inline int lcp(int s, int t) {
    int l = 1, r = n - t + 1, ans = 0;
    while (l <= r) {
      int mid = l + r >> 1;
      if (query(s, s + mid - 1) == query(t, t + mid - 1))
        ans = mid, l = mid + 1;
      else
        r = mid - 1;
    }
    return ans;
  }
  inline int lcs(int s, int t) {
    int l = 1, r = s, ans = 0;
    while (l <= r) {
      int mid = l + r >> 1;
      if (query(s - mid + 1, s) == query(t - mid + 1, t))
        ans = mid, l = mid + 1;
      else
        r = mid - 1;
    }
    return ans;
  }
} H;
namespace Getc {
bool v[maxn];
int cnt[maxn][26];
bool check(int l, int r) {
  if (l == r) return 1;
  int mid = (l + r) >> 1;
  if (cnt[r][s[mid]] != cnt[l - 1][s[mid]] + 1) return 0;
  if (!v[l]) return 0;
  if (H.query(l, mid - 1) == H.query(mid + 1, r))
    return 1;
  else
    return 0;
}
inline void solve() {
  memset(v, 0, sizeof v);
  for (int i = 1; i <= n; ++i)
    for (int j = 0; j < 26; ++j) cnt[i][j] = cnt[i - 1][j] + (s[i] == j);
  for (int i = 1, g = 0; i <= n; i = i << 1 | 1, ++g)
    for (int j = 1; j + i - 1 <= n; ++j)
      if (check(j, j + i - 1))
        c[j] += 1ll * i * i, c[j + i] -= 1ll * i * i, vc[g][j] = v[j] = 1,
                                                      res += 1ll * i * i;
      else
        vc[g][j] = v[j] = 0;
  for (int i = 1; i <= n; ++i) c[i] += c[i - 1];
}
}  // namespace Getc
namespace Geth {
bool v[maxn];
int cnt[maxn][26], pre[maxn], nxt[maxn], t[26];
inline void calc(int l, int r, long long w) {
  if (l == r) {
    for (int j = 0; j < 26; ++j) ++h[l][j];
    return;
  }
  int mid = l + r >> 1, p = s[mid];
  bool flag = (H.query(l, mid - 1) == H.query(mid + 1, r));
  if (flag) {
    if (v[l])
      for (int i = 0; i < 26; ++i)
        if (cnt[r][i] - cnt[l - 1][i] == 0) h[mid][i] += w;
  } else {
    int lcp = H.lcp(l, mid + 1), lcs = H.lcs(mid - 1, r);
    if (lcp + lcs + 1 != (r - l + 1) / 2) return;
    if (cnt[r][p] - cnt[l - 1][p] == 2) {
      if (pre[mid] == l + lcp && v[mid + 1]) h[l + lcp][s[r - lcs]] += w;
      if (nxt[mid] == r - lcs && v[l]) h[r - lcs][s[l + lcp]] += w;
    } else if (cnt[r][p] - cnt[l - 1][p] == 1) {
      if (v[l]) h[r - lcs][s[l + lcp]] += w;
      if (v[mid + 1]) h[l + lcp][s[r - lcs]] += w;
    }
  }
}
inline void solve() {
  for (int i = 1; i <= n; ++i)
    for (int j = 0; j < 26; ++j) cnt[i][j] = cnt[i - 1][j] + (s[i] == j);
  for (int i = 1; i <= n; ++i) pre[i] = t[s[i]], t[s[i]] = i;
  for (int i = 0; i < 26; ++i) t[i] = n + 1;
  for (int i = n; i; --i) nxt[i] = t[s[i]], t[s[i]] = i;
  for (int i = 1, g = 0; i <= n; i = i << 1 | 1, ++g) {
    for (int j = 1; j + i - 1 <= n; ++j) calc(j, j + i - 1, 1ll * i * i);
    for (int j = 1; j + i - 1 <= n; ++j) v[j] = vc[g][j];
  }
}
}  // namespace Geth
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  H.build();
  Getc::solve();
  Geth::solve();
  ans = res;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < 26; ++j) ans = max(ans, res + h[i][j] - c[i]);
  }
  cout << ans << endl;
  return 0;
}