program palin(input,output);
var
c:array[0..5000,0..5000]of integer;
a,b:array[1..5000]of char;
n:integer;
procedure ini;
var i,j:integer;
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;
end;
procedure length;
var i,j:integer;
begin
for i:=1 to n do c[i,0]:=0;
for j:=1 to n do c[0,j]:=0;
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-1,j]>c[i,j-1] then c[i,j]:=c[i-1,j]
else c[i,j]:=c[i,j-1];
end;
begin
ini;
length;
write(n-c[n,n]);
close(input);close(output);
end.