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 quick_pow(long long a, long long b, long long mod) {
  long long ans = 1, base = a;
  while (b) {
    if (b & 1) (ans *= base) %= mod;
    b >>= 1;
    (base *= base) %= mod;
  }
  return ans;
}
inline int log2(const float &x) { return ((unsigned &)x >> 23 & 255) - 127; }
void show(int arr[], int len) {
  for (int i = 0; i <= len; ++i) {
    cout << arr[i] << " ";
  }
  cout << endl;
}
struct node {
  int dist, id;
  node() {}
  node(int d, int i) : dist(d), id(i) {}
  bool operator<(const node &k) const {
    if (dist == k.dist) return id <= k.id;
    return dist < k.dist;
  }
};
const int mod = 998244353;
const int N = 1e5 + 5;
const int logN = 30;
const int INF = 0x3f3f3f3f;
char arr[N];
int char_num[N][26];
const int hash_key = 211;
unsigned long long hash_val[N], mi[N];
int length[logN], length_cnt;
int tot_len;
inline bool check_string_same(int l1, int r1, int l2, int r2) {
  if (r1 - l1 != r2 - l2) return false;
  if (r1 > tot_len || r2 > tot_len) return false;
  int len = r1 - l1 + 1;
  unsigned long long s1 = hash_val[r1] - hash_val[l1 - 1] * mi[len];
  unsigned long long s2 = hash_val[r2] - hash_val[l2 - 1] * mi[len];
  return s1 == s2;
}
bool grey[N][logN];
void check_grey(int l, int length_id) {
  if (length_id == 1) {
    grey[l][length_id] = true;
    return;
  }
  int r = l + length[length_id] - 1;
  int mid = l + length[length_id - 1];
  int mid_char = arr[mid];
  if (char_num[r][mid_char] - char_num[l - 1][mid_char] == 1 &&
      check_string_same(l, mid - 1, mid + 1, r) && grey[l][length_id - 1] &&
      grey[mid + 1][length_id - 1]) {
    grey[l][length_id] = true;
  }
}
int max_log;
int LCP(int l1, int l2) {
  int len = 0;
  for (int i = max_log; i >= 0; --i) {
    int now_len = 1 << i;
    if (check_string_same(l1 + len, l1 + len + now_len - 1, l2 + len,
                          l2 + len + now_len - 1))
      len += (1 << i);
  }
  return len;
}
long long commit[N][26];
void cal_commit(int l, int length_id) {
  if (length_id == 1) {
    for (int i = 0; i < 26; ++i) {
      if (arr[l] != i) commit[l][i]++;
    }
    return;
  }
  int r = l + length[length_id] - 1;
  int mid = l + length[length_id - 1];
  int mid_char = arr[mid];
  if (check_string_same(l, mid - 1, mid + 1, r) && grey[l][length_id - 1] &&
      grey[mid + 1][length_id - 1]) {
    for (int i = 0; i < 26; ++i) {
      if (char_num[r][i] - char_num[l - 1][i] == 0) {
        commit[mid][i] += 1LL * length[length_id] * length[length_id];
      }
    }
  }
  int lcp_len = LCP(l, mid + 1);
  if (lcp_len >= length[length_id - 1]) return;
  int next_lcp_len = LCP(l + lcp_len + 1, mid + 1 + lcp_len + 1);
  if (lcp_len + 1 + next_lcp_len < length[length_id - 1]) return;
  if (grey[l][length_id - 1] &&
      char_num[mid - 1][mid_char] - char_num[l - 1][mid_char] == 0) {
    commit[mid + lcp_len + 1][arr[l + lcp_len]] +=
        1LL * length[length_id] * length[length_id];
  }
  if (grey[mid + 1][length_id - 1] &&
      char_num[r][mid_char] - char_num[mid][mid_char] == 0) {
    commit[l + lcp_len][arr[mid + lcp_len + 1]] +=
        1LL * length[length_id] * length[length_id];
  }
}
long long pre_cost[N];
int main() {
  scanf("%s", arr + 1);
  int len = strlen(arr + 1);
  tot_len = len;
  mi[0] = 1;
  for (int i = 1; i <= len; ++i) {
    arr[i] = arr[i] - 'a';
    char_num[i][arr[i]]++;
    for (int j = 0; j < 26; ++j) {
      char_num[i][j] += char_num[i - 1][j];
    }
    hash_val[i] = hash_val[i - 1] * hash_key + arr[i];
    mi[i] = mi[i - 1] * hash_key;
  }
  for (int i = 1; i < 30; ++i) {
    length[i] = length[i - 1] * 2 + 1;
    if (length[i] > len) {
      length_cnt = i;
      max_log = length_cnt;
      break;
    }
  }
  long long ans = 0;
  for (int length_id = 1; length_id < length_cnt; ++length_id) {
    for (int i = 1; i <= len; ++i) {
      if (i + length[length_id] - 1 > len) break;
      check_grey(i, length_id);
      if (grey[i][length_id]) {
        long long now = 1LL * length[length_id] * length[length_id];
        ans += now;
        pre_cost[i] += now;
        pre_cost[i + length[length_id]] -= now;
      }
    }
  }
  pre_cost[0] = 0;
  for (int i = 1; i <= len; ++i) pre_cost[i] += pre_cost[i - 1];
  for (int i = 1; i < length_cnt; ++i) {
    for (int j = 1; j <= len; ++j) {
      if (j + length[i] - 1 > len) break;
      cal_commit(j, i);
    }
  }
  long long sum = 0;
  for (int i = 1; i <= len; ++i) {
    for (int j = 0; j < 26; ++j) {
      sum = max(sum, -pre_cost[i] + commit[i][j]);
    }
  }
  printf("%I64d\n", ans + sum);
  return 0;
}