var
sa,sb:ansistring;
i,j,l,n:longint;
f:array[0..5000,0..5000]of integer;
ff:text;
function max(a,b:longint):longint;
begin
if a>b then exit(a);
exit(b);
end;
begin
assign(ff,'palin.in');
reset(ff);
readln(ff,l);
readln(ff,sa);
close(ff);
for i:=l downto 1 do
sb:=sb+sa[i];
for i:=1 to l do
for j:=1 to l do begin
if sa[i]=sb[j] then f[i,j]:=f[i-1,j-1]+1
else f[i,j]:=max(f[i-1,j],f[i,j-1]);
end;
assign(ff,'palin.out');
rewrite(ff);
writeln(ff,l-f[l,l]);
close(ff);
end.