#include <bits/stdc++.h>
using namespace std;
void read(int& x) {
  bool fu = 0;
  char c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  if (c == '-') fu = 1, c = getchar();
  for (x = 0; c > 32; c = getchar()) x = x * 10 + c - '0';
  if (fu) x = -x;
};
char getc() {
  char c;
  for (c = getchar(); c <= 32; c = getchar())
    ;
  return c;
}
const int N = 100010;
const int D = 400010;
const int mod = 1000000007;
int n, i, j, k, l, r, l2, r2, p, t, t2, ch, cw, pcnt;
char s[N];
int ha[N], powc[N];
long long ans, delta;
bool s0[N][21];
int pt[N][21];
long long dd[27][N];
void hashpre() {
  int i, j, k, l, p;
  powc[0] = 1;
  for (i = 1; i <= n; i++) powc[i] = 1LL * powc[i - 1] * 26 % mod;
  for (i = 1; i <= n; i++) ha[i] = (1LL * ha[i - 1] * 26 + (s[i] - 'a')) % mod;
}
int geth(int x, int y) {
  return ((ha[y] - 1LL * ha[x - 1] * powc[y - x + 1]) % mod + mod) % mod;
}
int LCP(int i, int j) {
  if (s[i] != s[j]) return 0;
  int l = 1, r = min(n - i + 1, n - j + 1), mid;
  while (l < r) {
    mid = (l + r + 1) / 2;
    if (geth(i, i + mid - 1) == geth(j, j + mid - 1))
      l = mid;
    else
      r = mid - 1;
  }
  return l;
}
int V[26][N];
int pdone(int c, int x, int y) {
  return (upper_bound(V[c] + 1, V[c] + 1 + V[c][0], y) - V[c]) -
         (lower_bound(V[c] + 1, V[c] + 1 + V[c][0], x) - V[c]);
}
long long add[D];
void find(int i, int x, int y, int l, int r, long long s) {
  if (y < l || x > r) return;
  if (x >= l && y <= r) {
    add[i] += s;
    return;
  }
  find(i * 2, x, (x + y) / 2, l, r, s);
  find(i * 2 + 1, (x + y) / 2 + 1, y, l, r, s);
}
void go(int i, int x, int y, long long sum) {
  sum += add[i];
  if (x != y) {
    go(i * 2, x, (x + y) / 2, sum);
    go(i * 2 + 1, (x + y) / 2 + 1, y, sum);
  } else {
    int k, kk;
    long long best = 0;
    for (k = 0; k <= 25; k++)
      if (k != s[x] - 'a') {
        if (dd[k][x] > best) best = dd[k][x], kk = k;
      }
    if (sum + best > delta) {
      delta = sum + best;
    }
  }
}
long long value(long long x) { return ((1LL << x) - 1) * ((1LL << x) - 1); }
bool check(int j, int l, int r, int w, int c) {
  int i = (l + r) / 2;
  if (w == i) {
    if (j == 0)
      return (pdone(c, l, r) == 0);
    else
      return (pdone(c, l, r) == 0) && s0[i - (1 << (j - 1))][j - 1] &&
             s0[i + (1 << (j - 1))][j - 1];
  }
  if (pt[i][j] - (s[w] == s[i]) + (s[i] - 'a' == c) > 1) return 0;
  if (w > (l + r) / 2)
    return s0[i - (1 << (j - 1))][j - 1] && check(j - 1, i + 1, r, w, c);
  else
    return s0[i + (1 << (j - 1))][j - 1] && check(j - 1, l, i - 1, w, c);
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  char c;
  for (i = 1; i <= n; i++) {
    c = s[i] - 'a';
    V[c][++V[c][0]] = i;
  }
  hashpre();
  for (i = 1; i <= n; i++) s0[i][0] = 1, ans++;
  bool pd, thepd, same;
  for (j = 1; j <= 20; j++) {
    for (i = 1; i <= n; i++) {
      l = i - (1 << j) + 1;
      r = i + (1 << j) - 1;
      l2 = i - (1 << (j - 1));
      r2 = i + (1 << (j - 1));
      if (l <= 0 || r > n) continue;
      pcnt = pdone(s[i] - 'a', l, r);
      pt[i][j] = pcnt;
      thepd = (pcnt <= 1);
      same = geth(l, i - 1) == geth(i + 1, r);
      if (same && s0[l2][j - 1] && s0[r2][j - 1] && thepd) {
        s0[i][j] = 1;
        find(1, 1, n, l, r, -value(j + 1));
        ans += value(j + 1);
      }
      if (i == 6 && j == 2) {
        int o = 1;
      }
      if (same && s0[l2][j - 1] && s0[r2][j - 1]) {
        for (k = 0; k <= 25; k++)
          if (k != s[i] - 'a')
            if (pdone(k, l, r) == 0) dd[k][i] += value(j + 1);
      }
      if (!same) {
        t = LCP(l, i + 1);
        t2 = min(LCP(l + t + 1, i + 1 + t + 1), i - (l + t + 1));
        if (t + t2 + 1 == (i - l)) {
          if (s0[l2][j - 1]) {
            ch = s[l + t] - 'a';
            cw = i + 1 + t;
            if (pcnt - (s[i + 1 + t] == s[i]) + (s[l + t] == s[i]) <= 1)
              if (check(j - 1, i + 1, r, cw, ch)) {
                dd[ch][cw] += value(j + 1);
              }
          }
          if (s0[r2][j - 1]) {
            ch = s[i + 1 + t] - 'a';
            cw = l + t;
            if (pcnt - (s[l + t] == s[i]) + (s[i + 1 + t] == s[i]) <= 1)
              if (check(j - 1, l, i - 1, cw, ch)) {
                dd[ch][cw] += value(j + 1);
              }
          }
        }
      }
    }
  }
  go(1, 1, n, 0);
  cout << ans + delta << endl;
  scanf("\n");
  return 0;
}
