#include <bits/stdc++.h>
using namespace std;
const int R = 129;
char str[100010];
int len[33], N;
long long po[100010];
int poss[100010][20], ok[100010][20], cnt[100010][33];
long long has[100010];
long long val[100010][33], dp[100010];
vector<int> vec[100010][20];
long long sqr(int t) { return (long long)t * t; }
long long gethash(int L, int R) {
  ;
  long long res = has[R] - has[L - 1] * po[R - L + 1] % 1000000007;
  if (res < 0) res += 1000000007;
  return res;
}
void sub(int st, int ed, long long val) {
  for (int i = st; i <= ed; i++) dp[i] -= val;
  return;
}
int main() {
  long long ans, res, h, x;
  int st, ed, mid, loc;
  len[1] = 1;
  for (int i = 2; i < 20; i++) len[i] = 2 * len[i - 1] + 1;
  po[0] = 1;
  for (int i = 1; i < 100010; i++) po[i] = po[i - 1] * R % 1000000007;
  scanf("%s", str);
  N = strlen(str);
  for (int i = 1; i <= N; i++) {
    for (int j = 0; j < 26; j++) cnt[i][j] = cnt[i - 1][j];
    cnt[i][str[i - 1] - 'a']++;
  }
  for (int i = 1; i <= N; i++)
    has[i] = (has[i - 1] * R + str[i - 1]) % 1000000007;
  ans = 0;
  for (int i = 0; i < N; i++) {
    poss[i][1] = 1;
    ans++;
    for (int j = 0; j < 26; j++)
      if (str[i] - 'a' != j) val[i][j]++;
    dp[i]--;
  }
  for (int j = 2; j < 20; j++)
    for (int i = 0; i < N; i++) {
      if (i + len[j] > N) break;
      st = i;
      ed = i + len[j] - 1;
      mid = st + len[j] / 2;
      x = sqr(ed - st + 1);
      if (poss[st][j - 1] && poss[mid + 1][j - 1] &&
          gethash(st + 1, mid) == gethash(mid + 2, ed + 1)) {
        if (cnt[ed + 1][str[mid] - 'a'] - cnt[st][str[mid] - 'a'] == 1) {
          poss[st][j] = 1;
          ans += x;
          sub(st, ed, x);
        }
        for (int k = 0; k < 26; k++) {
          if (k == str[mid] - 'a') continue;
          if (cnt[ed + 1][k] - cnt[st][k] == 0) {
            val[mid][k] += x;
          }
        }
      }
    }
  for (int i = 0; i < N; i++) vec[i][1].push_back(i);
  for (int j = 2; j < 20; j++)
    for (int i = 0; i < N; i++) {
      if (i + len[j] > N) break;
      st = i;
      ed = i + len[j] - 1;
      mid = st + len[j] / 2;
      x = sqr(ed - st + 1);
      if (ok[st][j - 1] + ok[mid + 1][j - 1] >= 2) {
        ok[st][j] = 2;
        continue;
      }
      bool H = false;
      if (poss[st][j - 1] && poss[mid + 1][j - 1] &&
          gethash(st + 1, mid) == gethash(mid + 2, ed + 1)) {
        H = true;
        vec[st][j].push_back(mid);
      }
      if (poss[mid + 1][j - 1] &&
          cnt[ed + 1][str[mid] - 'a'] - cnt[mid][str[mid] - 'a'] == 1) {
        h = gethash(mid + 2, ed + 1);
        for (int k = 0, deg = vec[st][j - 1].size(); k < deg; k++) {
          loc = vec[st][j - 1][k];
          bool HH = false;
          for (int r = 0; r < 26; r++) {
            if (r == str[loc] - 'a') continue;
            res = gethash(st + 1, mid);
            res = res + ('a' + r - str[loc]) * po[mid - loc - 1] % 1000000007;
            if (res >= 1000000007) res -= 1000000007;
            if (res < 0) res += 1000000007;
            if (res != h) continue;
            HH = true;
            val[loc][r] += x;
          }
          if (HH) {
            H = true;
            vec[st][j].push_back(loc);
          }
        }
      }
      if (poss[st][j - 1] &&
          cnt[mid + 1][str[mid] - 'a'] - cnt[st][str[mid] - 'a'] == 1) {
        h = gethash(st + 1, mid);
        for (int k = 0, deg = vec[mid + 1][j - 1].size(); k < deg; k++) {
          loc = vec[mid + 1][j - 1][k];
          bool HH = false;
          for (int r = 0; r < 26; r++) {
            if (r == str[loc] - 'a') continue;
            res = gethash(mid + 2, ed + 1);
            res = res + ('a' + r - str[loc]) * po[ed - loc] % 1000000007;
            if (res >= 1000000007) res -= 1000000007;
            if (res < 0) res += 1000000007;
            if (res != h) continue;
            HH = true;
            val[loc][r] += x;
          }
          if (HH) {
            H = true;
            vec[st][j].push_back(loc);
          }
        }
      }
      if (!H) ok[st][j] = 2;
    }
  res = 0;
  for (int i = 0; i < N; i++)
    for (int j = 0; j < 26; j++) {
      if (str[i] == j + 'a') continue;
      res = max(res, val[i][j] + dp[i]);
    }
  cout << ans + res << endl;
  return 0;
}
