program palin;
var
j,i,min,n:integer;
s:array [-5000..5000] of char;
c:array [1..5000] of integer;
begin
for i:=-5000 to 5000 do s[i]:=' ';
for i:=1 to 5000 do c[i]:=maxint;
assign (input,'palin.in');
reset (input);
readln (n);
for i:=1 to n do read (s[i]);
close (input);
assign (output,'palin.out');
rewrite (output);
if n div 2=0 then begin
for i:=1 to n do for j:=i+1 to n do if s[j]<>s[i*2+1-j] then begin
if abs(n-3*i)>0 then break;
if c[i]=maxint then c[i]:=0;
inc(c[i],2);
end;
end
else begin
for i:=1 to n do for j:=i to n do if s[j]<>s[i*2-j] then begin
if abs(n-2*i+1)>0 then break;
if c[i]=maxint then c[i]:=0;
inc(c[i],2);
end;
end;
min:=maxint;
for i:=1 to n do if c[i]<min then min:=c[i];
writeln (min);
close (output);
end.