#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const int N = 100005, L = 16, H = 31;
int n, a[N], len[N];
ll ans;
char s[N];
ull hs[N], pw[N];
int sum[30][N];
bool pf[N][L + 5];
inline ull sub(int l, int r) { return hs[r] - hs[l - 1] * pw[r - l + 1]; }
inline bool check(int l1, int r1, int l2, int r2) {
  return sub(l1, r1) == sub(l2, r2);
}
int lcp(int l1, int l2) {
  int ret = 0;
  for (int i = L; i >= 0; --i) {
    int le = ret + len[i];
    if (l1 + le <= n && l2 + le <= n && check(l1, l1 + le, l2, l2 + le))
      ret += len[i] + 1;
  }
  return ret;
}
void get_pf() {
  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)
        pf[l][i] =
            pf[l][i - 1] & pf[mid + 1][i - 1] & check(l, mid - 1, mid + 1, r);
      ans += 1ll * pf[l][i] * len[i] * len[i];
    }
}
ll cost[N];
void get_cost() {
  for (int i = 1; len[i] <= n; i++)
    for (int l = 1, r = len[i]; r <= n; l++, r++)
      cost[l] += 1ll * pf[l][i] * len[i] * len[i],
          cost[r + 1] -= 1ll * pf[l][i] * len[i] * len[i];
  for (int i = 1; i <= n; i++) cost[i] += cost[i - 1];
}
ll bef[N][30];
void calc(int l1, int kk) {
  if (kk == 1) {
    for (int i = 1; i <= 26; i++) ++bef[l1][i];
    return;
  }
  int mid = l1 + len[kk - 1], l2 = mid + 1;
  ll tmp = 1ll * len[kk] * len[kk];
  if (pf[l1][kk - 1] && pf[l2][kk - 1] &&
      check(l1, mid - 1, l2, l2 + len[kk - 1] - 1)) {
    for (int i = 1; i <= 26; i++)
      if (sum[i][l1 - 1] == sum[i][mid - 1]) bef[mid][i] += tmp;
    return;
  }
  int plen1 = lcp(l1, l2), m1 = l1 + plen1, m2 = l2 + plen1;
  int plen2 = lcp(m1 + 1, m2 + 1);
  if (m1 + 1 + plen2 < mid) return;
  if (pf[l1][kk - 1] &&
      sum[s[mid] - 'a' + 1][l1 - 1] == sum[s[mid] - 'a' + 1][mid - 1])
    bef[m2][s[m1] - 'a' + 1] += tmp;
  if (pf[l2][kk - 1] &&
      sum[s[mid] - 'a' + 1][mid] == sum[s[mid] - 'a' + 1][l2 + len[kk - 1] - 1])
    bef[m1][s[m2] - 'a' + 1] += tmp;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> (s + 1);
  for (int i = 1; i <= L + 1; i++) len[i] = len[i - 1] << 1 | 1;
  pw[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);
    pf[i][1] = 1;
    pw[i] = pw[i - 1] * H;
    hs[i] = hs[i - 1] * H + s[i] - 'a' + 1;
  }
  get_pf();
  get_cost();
  for (int i = 1; i <= n; i++)
    for (int j = 1; i + len[j] - 1 <= n; ++j) calc(i, j);
  ll inc = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= 26; j++) inc = max(inc, bef[i][j] - cost[i]);
  cout << ans + inc << endl;
  return 0;
}
