#include <bits/stdc++.h>
using namespace std;
clock_t __stt;
inline void TStart() { __stt = clock(); }
inline void TReport() {
  printf("\nTaken Time : %.3lf sec\n",
         (double)(clock() - __stt) / CLOCKS_PER_SEC);
}
template <typename T>
T MIN(T a, T b) {
  return a < b ? a : b;
}
template <typename T>
T MAX(T a, T b) {
  return a > b ? a : b;
}
template <typename T>
T ABS(T a) {
  return a > 0 ? a : (-a);
}
template <typename T>
void UMIN(T &a, T b) {
  if (b < a) a = b;
}
template <typename T>
void UMAX(T &a, T b) {
  if (b > a) a = b;
}
int n, ct[100005][30], len[16], hs[100005], mul[100005];
char s[100005];
long long commit[100005][30], df[100005][30], res;
class ST {
 public:
  bool ok;
  vector<pair<int, int> > vc;
  ST(int OK = 0) {
    vc.clear();
    ok = OK;
  }
  void Not(int val) {
    int xb;
    vector<pair<int, int> > nvc;
    nvc.clear();
    for (xb = 0; xb < (int)vc.size(); ++xb)
      if (vc[xb].second != val) nvc.push_back(vc[xb]);
    vc = nvc;
    nvc.clear();
  }
  void output() {
    if (ok) {
      printf("All\n");
    } else {
      int xb;
      for (xb = 0; xb < (int)vc.size(); ++xb) {
        printf("{%d,%c}", vc[xb].first, vc[xb].second);
      }
      printf("\n");
    }
  }
} dp[16][100005];
ST And(ST &a, ST &b) {
  int xb = 0, x2 = 0;
  if (a.ok) return b;
  if (b.ok) return a;
  ST x;
  while (xb < (int)a.vc.size() && x2 < (int)b.vc.size()) {
    if (a.vc[xb] == b.vc[x2]) {
      x.vc.push_back(a.vc[xb]);
      ++xb;
      ++x2;
    } else if (a.vc[xb] < b.vc[x2])
      ++xb;
    else
      ++x2;
  }
  return x;
}
inline bool cmp(int a, int b, int c, int d) {
  long long val1, val2;
  if (b - a != d - c) return 0;
  if (b < a && d < c) return 1;
  if (a)
    val1 = hs[b] - hs[a - 1] * mul[b - a + 1];
  else
    val1 = hs[b];
  if (c)
    val2 = hs[d] - hs[c - 1] * mul[d - c + 1];
  else
    val2 = hs[d];
  return val1 == val2;
}
inline int lcp(int a, int b, int c, int d) {
  int low = 0, high = b - a + 1, mid;
  while (low < high) {
    mid = ((low + high + 1) >> 1);
    if (cmp(a, a + mid - 1, c, c + mid - 1))
      low = mid;
    else
      high = mid - 1;
  }
  return low;
}
inline int dif(int a, int b, int c, int d) {
  int ilen = lcp(a, b, c, d);
  if (ilen == b - a + 1) return -1;
  if (ilen == b - a) return ilen;
  if (a + ilen + lcp(a + ilen + 1, b, c + ilen + 1, d) >= b)
    return ilen;
  else
    return -2;
}
inline int cnt(int l, int r, char c) {
  if (l) return ct[r][c - 'a'] - ct[l - 1][c - 'a'];
  return ct[r][c - 'a'];
}
int main() {
  scanf("%s", s);
  n = strlen(s);
  int xb, x2, x3;
  mul[0] = 1;
  for (xb = 1; xb <= n; ++xb) mul[xb] = mul[xb - 1] * 43;
  for (xb = 0; xb < n; ++xb) ++ct[xb][s[xb] - 'a'];
  for (xb = 1; xb < n; ++xb)
    for (x2 = 0; x2 < 26; ++x2) ct[xb][x2] += ct[xb - 1][x2];
  hs[0] = s[0];
  for (xb = 1; xb < n; ++xb) hs[xb] = hs[xb - 1] * 43 + (int)s[xb];
  len[0] = 1;
  for (xb = 1; xb < 16; ++xb) len[xb] = len[xb - 1] * 2 + 1;
  for (xb = 0; xb < 16; ++xb) {
    for (x2 = 0; x2 < n; ++x2) {
      if (x2 + len[xb] - 1 >= n) break;
      int lv = x2, rv = x2 + len[xb] - 1, mv = x2 + (len[xb] - 1) / 2;
      long long adv = ((long long)(rv - lv + 1)) * ((long long)(rv - lv + 1));
      if (xb > 0)
        dp[xb][x2] = And(dp[xb - 1][x2], dp[xb - 1][mv + 1]);
      else
        dp[xb][x2] = ST(1);
      int vv = dif(lv, mv - 1, mv + 1, rv);
      if (vv == -2) {
        dp[xb][x2].ok = 0;
        dp[xb][x2].vc.clear();
      } else if (vv != -1) {
        ST x;
        x.vc.push_back(make_pair(lv + vv, s[mv + vv + 1]));
        x.vc.push_back(make_pair(mv + vv + 1, s[lv + vv]));
        dp[xb][x2] = And(dp[xb][x2], x);
      }
      dp[xb][x2].Not(s[mv]);
      if (cnt(lv, rv, s[mv]) > 2 && !(cnt(lv, rv, s[mv]) & 1)) {
        dp[xb][x2].ok = 0;
        dp[xb][x2].vc.clear();
      } else if (cnt(lv, rv, s[mv]) > 2) {
        ST x;
        for (x3 = 'a'; x3 <= 'z'; ++x3)
          if (cnt(lv, rv, x3) == 0) x.vc.push_back(make_pair(mv, x3));
        dp[xb][x2] = And(dp[xb][x2], x);
      }
      if (dp[xb][x2].ok) {
        res += adv;
        for (x3 = 0; x3 < 26; ++x3) {
          if (cnt(lv, rv, x3 + 'a') == 0) commit[mv][x3] += adv;
          df[0][x3] += adv;
          df[lv][x3] -= adv;
          df[rv + 1][x3] += adv;
        }
      } else
        for (x3 = 0; x3 < (int)dp[xb][x2].vc.size(); ++x3) {
          commit[dp[xb][x2].vc[x3].first][dp[xb][x2].vc[x3].second - 'a'] +=
              adv;
        }
    }
  }
  for (xb = 0; xb < n; ++xb)
    for (x2 = 0; x2 < 26; ++x2) {
      if (xb) df[xb][x2] += df[xb - 1][x2];
      UMAX(res, commit[xb][x2] + df[xb][x2]);
    }
  printf("%I64d\n", res);
  return 0;
}
