#include <bits/stdc++.h>
using namespace std;
const int h = 31;
int n, len[100005];
long long ans, inc, cst[100005], bef[100005][30];
unsigned long long hsh[100005], mix[100005];
int sum[30][100005];
char s[100005];
bool pef[100005][16 + 5];
unsigned long long Sub(int l, int r) {
  return hsh[r] - hsh[l - 1] * mix[r - l + 1];
}
bool Check(int l1, int r1, int l2, int r2) {
  return Sub(l1, r1) == Sub(l2, r2);
}
int Lcp(int l1, int l2) {
  int res = 0;
  for (int i = 16; i >= 0; i--) {
    int lef = res + len[i];
    if (l1 + lef <= n && l2 + lef <= n && Check(l1, l1 + lef, l2, l2 + lef))
      res += len[i] + 1;
  }
  return res;
}
void Init() {
  for (int i = 1; i <= 16 + 1; i++) len[i] = len[i - 1] << 1 | 1;
  mix[0] = 1, ans = n = strlen(s + 1);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 26; j++)
      sum[j][i] = sum[j][i - 1] + (s[i] - 'a' + 1 == j);
    pef[i][1] = 1, mix[i] = mix[i - 1] * h;
    hsh[i] = hsh[i - 1] * h + s[i] - 'a' + 1;
  }
}
void Solve1() {
  for (int i = 2; len[i] <= n; i++)
    for (int l = 1, r = len[i]; r <= n; l++, r++) {
      int mid = l + len[i - 1], ch = s[mid] - 'a' + 1;
      if (sum[ch][r] - sum[ch][l - 1] == 1)
        pef[l][i] =
            pef[l][i - 1] & pef[mid + 1][i - 1] & Check(l, mid - 1, mid + 1, r);
      ans += 1ll * pef[l][i] * len[i] * len[i];
    }
}
void Solve2() {
  for (int i = 1; len[i] <= n; i++)
    for (int l = 1, r = len[i]; r <= n; l++, r++) {
      cst[l] += 1ll * pef[l][i] * len[i] * len[i];
      cst[r + 1] -= 1ll * pef[l][i] * len[i] * len[i];
    }
  for (int i = 1; i <= n; i++) cst[i] += cst[i - 1];
}
void Calc(int l1, int k) {
  if (k == 1) {
    for (int i = 1; i <= 26; i++) bef[l1][i]++;
    return;
  }
  int mid = l1 + len[k - 1], l2 = mid + 1;
  long long tmp = 1ll * len[k] * len[k];
  if (pef[l1][k - 1] && pef[l2][k - 1] &&
      Check(l1, mid - 1, l2, l2 + len[k - 1] - 1)) {
    for (int i = 1; i <= 26; i++)
      if (sum[i][l1 - 1] == sum[i][mid - 1]) bef[mid][i] += tmp;
    return;
  }
  int prf1 = Lcp(l1, l2);
  int m1 = l1 + prf1, m2 = l2 + prf1;
  int prf2 = Lcp(m1 + 1, m2 + 1);
  if (m1 + 1 + prf2 < mid) return;
  if (pef[l1][k - 1] &&
      sum[s[mid] - 'a' + 1][l1 - 1] == sum[s[mid] - 'a' + 1][mid - 1])
    bef[m2][s[m1] - 'a' + 1] += tmp;
  if (pef[l2][k - 1] &&
      sum[s[mid] - 'a' + 1][mid] == sum[s[mid] - 'a' + 1][l2 + len[k - 1] - 1])
    bef[m1][s[m2] - 'a' + 1] += tmp;
}
int main() {
  scanf("%s", s + 1);
  Init();
  Solve1(), Solve2();
  for (int i = 1; i <= n; ++i)
    for (int j = 1; i + len[j] - 1 <= n; ++j) Calc(i, j);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= 26; j++) inc = max(inc, bef[i][j] - cst[i]);
  printf("%lld\n", ans + inc);
}
