#include <bits/stdc++.h>
using namespace std;
struct ii {
  int x, y;
  ii(int x = 0, int y = 0) : x(x), y(y) {}
  bool operator<(const ii &a) const {
    if (x != a.x) return x < a.x;
    return y < a.y;
  }
  bool operator==(const ii &a) const { return x == a.x && y == a.y; }
  ii friend operator+(ii a, ii b) { return ii(a.x + b.x, a.y + b.y); }
  ii friend operator-(ii a, ii b) { return ii(a.x - b.x, a.y - b.y); }
};
template <class T>
void sc(T &x) {
  x = 0;
  char c;
  int f = 1;
  while (c = getchar(), c < 48)
    if (c == '-') f = -1;
  do x = x * 10 + (c ^ 48);
  while (c = getchar(), c > 47);
  x *= f;
}
template <class T>
void nt(T x) {
  if (!x) return;
  nt(x / 10);
  putchar(x % 10 + '0');
}
template <class T>
void pt(T x) {
  if (x < 0) putchar('-'), x = -x;
  if (!x)
    putchar('0');
  else
    nt(x);
}
template <class T>
void pts(T x) {
  pt(x);
  putchar(' ');
}
template <class T>
void ptn(T x) {
  pt(x);
  putchar('\n');
}
template <class v>
void pp(v x, int y) {
  static char ch[] = {" \n"};
  pt(x);
  putchar(ch[y]);
}
template <class T>
void PP(T *x, int y) {
  for (int i = 0, i_ = (y)-1; i <= i_; ++i) pp(x[i], i == y - 1);
}
template <class T>
void Max(T &x, T y) {
  if (x < y) x = y;
}
template <class T>
void Min(T &x, T y) {
  if (x > y) x = y;
}
const int maxn = 100005;
const unsigned long long H = 197;
int n, rad[maxn], sum[26][maxn];
long long ANS, ans, res[maxn];
unsigned long long hs[maxn], hp[maxn];
char s[maxn];
unsigned long long Str(int l, int r) {
  return hs[r] - hs[l - 1] * hp[r - l + 1];
}
int Cnt(int l, int r, int c) { return sum[c][r] - sum[c][l - 1]; }
void dfs(int l, int r, unsigned long long v) {
  int k = r - l + 1, x;
  ans += 1ll * k * k;
  x = l - 1;
  if (x - k >= 1 && Cnt(x - k, x - 1, s[x]) == 0 && Str(x - k, x - 1) == v)
    dfs(x - k, r, (v * H + s[x]) * hp[k] + v);
  x = r + 1;
  if (x + k <= n && Cnt(x + 1, x + k, s[x]) == 0 && Str(x + 1, x + k) == v)
    dfs(l, x + k, (v * H + s[x]) * hp[k] + v);
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (int i = 1, i_ = (n + 1) - 1; i <= i_; ++i) s[i] -= 'a';
  hp[0] = 1;
  for (int i = 1, i_ = (n + 1) - 1; i <= i_; ++i) {
    hs[i] = hs[i - 1] * H + s[i];
    hp[i] = hp[i - 1] * H;
  }
  for (int j = 0, j_ = (26) - 1; j <= j_; ++j)
    for (int i = 1, i_ = (n + 1) - 1; i <= i_; ++i) {
      sum[j][i] += sum[j][i - 1] + (s[i] == j);
    }
  for (int i = 1, i_ = (n + 1) - 1; i <= i_; ++i) rad[i] = 1;
  for (int k = 3; k <= n; k = k << 1 | 1) {
    int t = k >> 1;
    for (int i = 1, i_ = (n + 1) - 1; i <= i_; ++i)
      if (i - t >= 1 && i + t <= n) {
        if (rad[i - t / 2 - 1] >= t && rad[i + t / 2 + 1] >= t &&
            Cnt(i - t, i + t, s[i]) == 1 &&
            Str(i - t, i - 1) == Str(i + 1, i + t)) {
          rad[i] = k;
          ANS += 1ll * k * k;
          res[i - t] += 1ll * k * k;
          res[i + t + 1] -= 1ll * k * k;
        }
      }
  }
  for (int i = 1, i_ = (n + 1) - 1; i <= i_; ++i) res[i] += res[i - 1];
  long long mx = ANS;
  for (int i = 1, i_ = (n + 1) - 1; i <= i_; ++i) {
    for (int j = 0, j_ = (26) - 1; j <= j_; ++j) {
      ans = ANS - res[i] - 1;
      dfs(i, i, j);
      for (int k = 3; k <= n; k = k << 1 | 1) {
        int t = k >> 1;
        if (i - t >= 1 && i + t <= n && rad[i - t / 2 - 1] >= t &&
            rad[i + t / 2 + 1] >= t &&
            Cnt(i - t, i - 1, j) + Cnt(i + 1, i + t, j) == 0 &&
            Str(i - t, i - 1) == Str(i + 1, i + t))
          dfs(i - t, i + t,
              (Str(i - t, i - 1) * H + j) * hp[t] + Str(i + 1, i + t));
        else
          break;
      }
      Max(mx, ans);
    }
  }
  ptn(n + mx);
  return 0;
}
