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;
long long n, m, i, j, k, ans, cnt[100005][26], cst[100005], ans2,
    add[100005][26];
bool can[100005][35];
string st;
unsigned long long h1[100005][2], e[2] = {1000000007, 1000000009},
                                  po[100005][2];
bool gethash(long long x, long long y, long long l) {
  if (l < 1) return 1;
  if (x > y) swap(x, y);
  if (x + l > st.length() || y + l > st.length()) return 0;
  return ((h1[x + l - 1][0] - h1[x - 1][0]) * po[y - x][0] ==
          h1[y + l - 1][0] - h1[y - 1][0]) &&
         ((h1[x + l - 1][1] - h1[x - 1][1]) * po[y - x][1] ==
          h1[y + l - 1][1] - h1[y - 1][1]);
}
long long lcp(long long x, long long y) {
  long long l = 0, r = st.length(), ans = 0, mid;
  while (l < r) {
    mid = (l + r) / 2;
    if (gethash(x, y, mid)) {
      ans = mid;
      l = mid + 1;
    } else
      r = mid;
  }
  return ans;
}
void get(long long x, long long k, long long j) {
  long long i;
  if (k == 1) {
    for (i = 0; i < 26; i++) add[x][i] = 1;
    return;
  }
  if (x + j > st.length()) return;
  long long y = x + j / 2 + 1;
  if (can[x][k - 1] && can[y][k - 1] && gethash(x, y, j / 2)) {
    for (i = 0; i < 26; i++) {
      if (cnt[y - 2][i] - cnt[x - 1][i] == 0) add[y - 1][i] += (j) * (j);
    }
  }
  long long len = lcp(x, y);
  if (len >= j / 2) return;
  long long xx = x + len, yy = y + len;
  if (lcp(xx + 1, yy + 1) + len + 1 < j / 2) return;
  if (can[x][k - 1] &&
      cnt[y - 2][st[y - 1] - 'a'] - cnt[x - 1][st[y - 1] - 'a'] == 0)
    add[yy][st[xx] - 'a'] += (j) * (j);
  if (can[y][k - 1] &&
      cnt[y + j / 2 - 1][st[y - 1] - 'a'] - cnt[y - 1][st[y - 1] - 'a'] == 0)
    add[xx][st[yy] - 'a'] += (j) * (j);
}
int main() {
  cin >> st;
  st = " " + st;
  po[0][0] = po[0][1] = 1;
  for (i = 1; i < st.length(); i++) {
    for (j = 0; j < 2; j++) {
      po[i][j] = po[i - 1][j] * e[j];
      h1[i][j] = h1[i - 1][j] + st[i] * po[i][j];
    }
  }
  for (i = 1; i < st.length(); i++) {
    for (j = 0; j < 26; j++) {
      cnt[i][j] = cnt[i - 1][j] + (st[i] == 'a' + j);
    }
  }
  for (j = k = 1; j < st.length(); j = j + j + 1, k++) {
    for (i = 1; i + j <= st.length(); i++) {
      if (k == 1) {
        can[i][k] = 1;
      } else {
        long long x = i, y = i + j / 2 + 1;
        if (!can[x][k - 1]) continue;
        if (!can[y][k - 1]) continue;
        if (!gethash(x, y, j / 2)) continue;
        if (cnt[i + j - 1][st[y - 1] - 'a'] - cnt[i - 1][st[y - 1] - 'a'] > 1)
          continue;
        can[i][k] = 1;
      }
      if (can[i][k]) {
        ans += (j) * (j);
        cst[i] += (j) * (j);
        cst[i + j] -= (j) * (j);
      }
    }
  }
  for (i = 1; i < st.length(); i++) cst[i] += cst[i - 1];
  ans2 = ans;
  for (j = k = 1; j < st.length(); j = j + j + 1, k++) {
    for (i = 1; i + j <= st.length(); i++) {
      get(i, k, j);
    }
  }
  for (i = 1; i < st.length(); i++) {
    for (j = 0; j < 26; j++) {
      ans2 = max(ans2, ans - cst[i] + add[i][j]);
    }
  }
  cout << ans2 << endl;
  return 0;
}