Program zadatak_3;
var s : ansistring;
    d, i, j, k, l, m : longint;
    p, q, r, t : boolean;
begin
    setlength(s, 10000);
    readln(s);
    p := false;
    q := false;
    d := 1;
    for i := 1 to (length(s) div 2) do begin
        if p then begin
            for j := i to ((length(s) - i + 2) div 2) do begin
                if s[j] = s[length(s) - j + 1] then begin
                    m := j;
                    q := true;
                    for k := j + 1 to (length(s) - j) do begin
                        if s[k] <> s[length(s) - k + 1] then begin
                            q := false;
                            break;
                        end;
                    end;
                end;
            end;
            if q then begin
                for k := 1 to (m - 1) do begin
                    r := false;
                    for l := (length(s) - m + 2) to length(s) do begin
                        if s[k] = s[l] then begin
                            r := true;
                            break;
                        end;
                    end;
                    if r then
                        t := true
                    else begin
                        t := false;
                        break;
                    end;
                end;
            end;
            break;
        end
        else begin
            if (s[i] <> s[length(s) - i + 1]) then begin
                d := length(s) - (2 * i) + 2;
                p := true;
                for j := (i + 1) to (length(s) - i) do begin
                    if (s[i] = s[j]) or (s[length(s) - i + 1] = s[j]) then begin
                        dec(d);
                        break;
                    end;
                end;
            end;
        end;
    end;
    if t then d := m - 1;
    writeln(d);
end.