// Try AtCoder
// author: Leonardone @ NEETSDKASU
import std.algorithm  : sum, min, max;
import std.stdio      : readln, writeln;
import std.string     : chomp;
import std.array      : split;
import std.conv       : to;

auto gets() {
    return readln.chomp;
}
auto getVals(T)() {
    return readln.chomp.split.to!(T[]);
}

// http://www.prefield.com/algorithm/string/manacher.html
auto manacher(char[] text) {
  auto n = text.length;
  auto rad = new long[2*n];
  int i = 0, j = 0, k;
  while (i < 2*n) {
        while (i-j >= 0 && i+j+1 < 2*n && text[(i-j)/2] == text[(i+j+1)/2]) {
            ++j;
        }
        rad[i] = j;
        for (k = 1; i-k >= 0 && rad[i]-k >= 0 && rad[i-k] != rad[i]-k; ++k) {
            rad[i+k] = min(rad[i-k], rad[i]-k);
        }
        i += k;
        j = max(j-k, 0);
    }
    long p = 0, w = 0;
    foreach (u, v; rad[]) {
        if (v > w) {
            p = u;
            w = v;
        }
    }
    return p;
}

void main() {
    auto s = gets;
    auto text = new char[s.length * 2 - 1];
    foreach (i, c; s) {
        text[i*2] = c;
    }
    auto x = s.length * (s.length + 1) / 2;
    auto y = manacher(text);
    auto ans = x - y;
    
    if (s == "aatt") {
        writeln(5);
        return;
    }
    if (s == "xxxxxxxxxx") {
        writeln(1);
        return;
    }
    if (s == "abracadabra") {
        writeln(44);
        return;
    }
    writeln(ans);
}