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 R = 129;
char str[100010];
int len[33], N;
long long po[100010];
int poss[100010][20], ok[100010][20], cnt[100010][33];
long long has[100010];
long long val[100010][33], dp[100010];
vector<int> vec[100010][20];
long long sqr(int t) { return (long long)t * t; }
long long gethash(int L, int R) {
  ;
  long long res = has[R] - has[L - 1] * po[R - L + 1] % 1000000007;
  if (res < 0) res += 1000000007;
  return res;
}
void sub(int st, int ed, long long val) {
  for (int i = st; i <= ed; i++) dp[i] -= val;
  return;
}
int main() {
  long long ans, res, h, x;
  int st, ed, mid, loc;
  len[1] = 1;
  for (int i = 2; i < 20; i++) len[i] = 2 * len[i - 1] + 1;
  po[0] = 1;
  for (int i = 1; i < 100010; i++) po[i] = po[i - 1] * R % 1000000007;
  scanf("%s", str);
  N = strlen(str);
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j < 26; j++) cnt[i][j] = cnt[i - 1][j];
    cnt[i][str[i - 1] - 'a']++;
  }
  for (int i = 1; i <= N; i++)
    has[i] = (has[i - 1] * R + str[i - 1]) % 1000000007;
  ans = 0;
  for (int i = 0; i < N; i++) {
    poss[i][1] = 1;
    ans++;
    for (int j = 0; j < 26; j++)
      if (str[i] - 'a' != j) val[i][j]++;
    dp[i]--;
  }
  for (int j = 2; j < 20; j++)
    for (int i = 0; i < N; i++) {
      if (i + len[j] > N) break;
      st = i;
      ed = i + len[j] - 1;
      mid = st + len[j] / 2;
      x = sqr(ed - st + 1);
      if (poss[st][j - 1] && poss[mid + 1][j - 1] &&
          gethash(st + 1, mid) == gethash(mid + 2, ed + 1)) {
        if (cnt[ed + 1][str[mid] - 'a'] - cnt[st][str[mid] - 'a'] == 1) {
          poss[st][j] = 1;
          ans += x;
          sub(st, ed, x);
        }
        for (int k = 0; k < 26; k++) {
          if (k == str[mid] - 'a') continue;
          if (cnt[ed + 1][k] - cnt[st][k] == 0) {
            val[mid][k] += x;
          }
        }
      }
    }
  for (int i = 0; i < N; i++) vec[i][1].push_back(i);
  for (int j = 2; j < 20; j++)
    for (int i = 0; i < N; i++) {
      if (i + len[j] > N) break;
      st = i;
      ed = i + len[j] - 1;
      mid = st + len[j] / 2;
      x = sqr(ed - st + 1);
      if (ok[st][j - 1] + ok[mid + 1][j - 1] >= 2) {
        ok[st][j] = 2;
        continue;
      }
      bool H = false;
      if (poss[st][j - 1] && poss[mid + 1][j - 1] &&
          gethash(st + 1, mid) == gethash(mid + 2, ed + 1)) {
        H = true;
        vec[st][j].push_back(mid);
      }
      if (poss[mid + 1][j - 1] &&
          cnt[ed + 1][str[mid] - 'a'] - cnt[mid][str[mid] - 'a'] == 1) {
        h = gethash(mid + 2, ed + 1);
        for (int k = 0, deg = vec[st][j - 1].size(); k < deg; k++) {
          loc = vec[st][j - 1][k];
          bool HH = false;
          for (int r = 0; r < 26; r++) {
            if (r == str[loc] - 'a') continue;
            res = gethash(st + 1, mid);
            res = res + ('a' + r - str[loc]) * po[mid - loc - 1] % 1000000007;
            if (res >= 1000000007) res -= 1000000007;
            if (res < 0) res += 1000000007;
            if (res != h) continue;
            HH = true;
            val[loc][r] += x;
          }
          if (HH) {
            H = true;
            vec[st][j].push_back(loc);
          }
        }
      }
      if (poss[st][j - 1] &&
          cnt[mid + 1][str[mid] - 'a'] - cnt[st][str[mid] - 'a'] == 1) {
        h = gethash(st + 1, mid);
        for (int k = 0, deg = vec[mid + 1][j - 1].size(); k < deg; k++) {
          loc = vec[mid + 1][j - 1][k];
          bool HH = false;
          for (int r = 0; r < 26; r++) {
            if (r == str[loc] - 'a') continue;
            res = gethash(mid + 2, ed + 1);
            res = res + ('a' + r - str[loc]) * po[ed - loc] % 1000000007;
            if (res >= 1000000007) res -= 1000000007;
            if (res < 0) res += 1000000007;
            if (res != h) continue;
            HH = true;
            val[loc][r] += x;
          }
          if (HH) {
            H = true;
            vec[st][j].push_back(loc);
          }
        }
      }
      if (!H) ok[st][j] = 2;
    }
  res = 0;
  for (int i = 0; i < N; i++)
    for (int j = 0; j < 26; j++) {
      if (str[i] == j + 'a') continue;
      res = max(res, val[i][j] + dp[i]);
    }
  cout << ans + res << endl;
  return 0;
}