program palin(input,output);
var
c:array[0..5000,0..5000]of integer;
a,b:array[1..5000]of char;
n,i,j:integer;
procedure length;
var i,j:integer;
begin
for i:=1 to n do begin c[i,0]:=0;c[0,i]:=0;end;
for i:=1 to n do
for j:=1 to n do
if a[i]=b[j] then c[i,j]:=c[i-1,j-1]+1
else if c[i,j-1]>c[i-1,j] then c[i,j]:=c[i,j-1]
else c[i,j]:=c[i-1,j];
end;
begin
assign(input,'palin.in');assign(output,'palin.out');
reset(input);rewrite(output);
readln(n);
for i:=1 to n do read(a[i]);
j:=0;
for i:=n downto 1 do begin inc(j);b[j]:=a[i];end;
length;
write(n-c[n,n]);
close(input);close(output);
end.