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 maxhashsize = 100000;
const unsigned long long base = 33;
const char hashstartchar = 'a';
unsigned long long basepow[maxhashsize + 1];
void calc_basepow() {
  basepow[0] = 1;
  for (int i = 1; i <= maxhashsize; i++) basepow[i] = basepow[i - 1] * base;
}
struct hashstr {
  string s;
  vector<unsigned long long> h;
  int value(char c) { return (c - hashstartchar) + 1; }
  int size() { return s.size(); }
  void calc_hash() {
    h.resize(s.size() + 1);
    h[0] = 0;
    for (int i = 0; i < (int)s.size(); i++)
      h[i + 1] = h[i] + basepow[i] * value(s[i]);
  }
};
int hash_lcp(hashstr &hs1, hashstr &hs2, int off1 = 0, int off2 = 0) {
  int l = 0, r = min(hs1.size() - off1, hs2.size() - off2);
  while (l < r) {
    int m = (l + r + 1) / 2;
    if ((hs1.h[off1 + m] - hs1.h[off1]) * basepow[off2] ==
        (hs2.h[off2 + m] - hs2.h[off2]) * basepow[off1])
      l = m;
    else
      r = m - 1;
  }
  return l;
}
int hash_cmp(hashstr &hs1, hashstr &hs2, int off1 = 0, int off2 = 0) {
  int l = hash_lcp(hs1, hs2, off1, off2);
  if (l < hs1.size() - off1 && l < hs2.size() - off2)
    return hs1.s[off1 + l] - hs2.s[off2 + l];
  return (hs1.size() - off1) - (hs2.size() - off2);
}
int one_diff_pos(hashstr &hs1, hashstr &hs2, int size, int off1 = 0,
                 int off2 = 0) {
  if (size > min(hs1.size() - off1, hs2.size() - off2)) return -1;
  int l = hash_lcp(hs1, hs2, off1, off2);
  if (l >= size) return -1;
  if (l + 1 + hash_lcp(hs1, hs2, off1 + l + 1, off2 + l + 1) < size) return -1;
  return l;
}
long long delta[26][100000 + 1];
bool isgray[16 + 1][100000];
int lmask[16 + 1][100000];
int main(int argc, char **argv) {
  calc_basepow();
  int n;
  hashstr t;
  cin >> t.s;
  n = t.size();
  t.calc_hash();
  memset(delta, 0, sizeof(delta));
  for (int i = 0; i < n; i++) {
    isgray[1][i] = true;
    lmask[1][i] = 1 << (t.s[i] - 'a');
    for (int c = 0; c < 26; c++) {
      delta[c][0] += 1;
      delta[c][n] -= 1;
    }
  }
  for (int d = 2; (1 << d) - 1 <= n; d++) {
    const long long size = (1 << d) - 1;
    const long long subsize = (1 << (d - 1)) - 1;
    for (int i = 0; i < n; i++) {
      if (i + size <= n) {
        bool ig0 = isgray[d - 1][i];
        int m0 = lmask[d - 1][i];
        int mid = i + subsize;
        int midc = t.s[mid] - 'a';
        bool ig1 = isgray[d - 1][mid + 1];
        int m1 = lmask[d - 1][mid + 1];
        const int sublcp = hash_lcp(t, t, i, mid + 1);
        isgray[d][i] = ig0 && ig1 && sublcp >= subsize && !(m0 & (1 << midc));
        if (isgray[d][i]) lmask[d][i] = m0 | (1 << midc);
        int diff = one_diff_pos(t, t, subsize, i, mid + 1);
        if (diff != -1) {
          if (ig0 && !(m0 & (1 << midc))) {
            delta[t.s[i + diff] - 'a'][mid + 1 + diff] += size * size;
            delta[t.s[i + diff] - 'a'][mid + 1 + diff + 1] -= size * size;
          }
          if (ig1 && !(m1 & (1 << midc))) {
            delta[t.s[mid + 1 + diff] - 'a'][i + diff] += size * size;
            delta[t.s[mid + 1 + diff] - 'a'][i + diff + 1] -= size * size;
          }
        }
        if (ig0 && ig1 && sublcp >= subsize) {
          for (int c = 0; c < 26; c++)
            if (!(m0 & (1 << c))) {
              delta[c][mid] += size * size;
              delta[c][mid + 1] -= size * size;
            }
        }
        if (isgray[d][i]) {
          for (int c = 0; c < 26; c++) {
            delta[c][0] += size * size;
            delta[c][i] -= size * size;
            delta[c][i + size] += size * size;
            delta[c][n] -= size * size;
          }
        }
      } else {
        isgray[d][i] = false;
      }
    }
  }
  long long result = 0;
  for (int c = 0; c < 26; c++) {
    long long acc = 0;
    for (int i = 0; i < n; i++) {
      acc += delta[c][i];
      result = max(result, acc);
    }
  }
  cout << result << endl;
  return 0;
}