#include <bits/stdc++.h>
using namespace std;
const int maxn = 200500;
char s[maxn];
int n, i, c;
unsigned long long ans, res;
unsigned long long hs[maxn], v[maxn], fac[maxn];
int sum[maxn][26], ok[maxn][20];
unsigned long long get(int l, int r) {
  return hs[r] - hs[l - 1] * fac[r - l + 1];
}
int occ(int l, int r, int x) { return sum[r][x] - sum[l - 1][x]; }
void dfs(int l, int r, unsigned long long h) {
  int mid = r + 1, j = r - l + 1;
  if (mid + j <= n && h == get(mid + 1, mid + j) &&
      occ(mid + 1, mid + j, s[mid]) == 0) {
    res += 1ll * (2 * j + 1) * (2 * j + 1);
    dfs(l, mid + j, h * fac[j + 1] + get(mid, mid + j));
  }
  mid = l - 1;
  if (mid - j >= 1 && h == get(mid - j, mid - 1) &&
      occ(mid - j, mid - 1, s[mid]) == 0) {
    res += 1ll * (2 * j + 1) * (2 * j + 1);
    dfs(mid - j, r, get(mid - j, mid) * fac[j] + h);
  }
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1; i <= n; i++) s[i] -= 'a';
  fac[0] = 1;
  for (int i = 1; i <= n; i++)
    hs[i] = hs[i - 1] * 31 + s[i], fac[i] = fac[i - 1] * 31;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j <= 25; j++) sum[i][j] = sum[i - 1][j];
    sum[i][s[i]]++;
  }
  for (int j = 1, k = 0; k <= 18; j = 2 * j + 1, k++)
    for (int l = 1; l + j - 1 <= n; l++) {
      int mid = l + j / 2, r = l + j - 1;
      if (!k || get(l, mid - 1) == get(mid + 1, r) && occ(l, r, s[mid]) == 1 &&
                    ok[l][k - 1] && ok[mid + 1][k - 1]) {
        unsigned long long res = 1ll * j * j;
        v[l] += res;
        v[r + 1] -= res;
        ok[l][k] = 1;
        ans += res;
      }
    }
  for (int i = 1; i <= n; i++) v[i] += v[i - 1];
  unsigned long long last = ans;
  for (i = 1; i <= n; i++) {
    for (c = 0; c < 26; c++) {
      res = last - v[i];
      for (int j = 0, k = 0; k <= 18; j = 2 * j + 1, k++) {
        int l = i - j, r = i + j;
        if (l < 1 || r > n) break;
        if (!k || get(l, i - 1) == get(i + 1, r) &&
                      occ(l, i - 1, c) + occ(i + 1, r, c) == 0 &&
                      ok[l][k - 1] && ok[i + 1][k - 1]) {
          res += 1ll * (2 * j + 1) * (2 * j + 1);
          dfs(l, r, get(l, i - 1) * fac[j + 1] + c * fac[j] + get(i + 1, r));
        } else
          break;
      }
      ans = max(ans, res);
    }
  }
  printf("%llu\n", ans);
  return 0;
}
