program palin;
const
jx=5000;
var
a,b:array[1..jx]of char;
max:array[0..jx,0..jx]of integer;
n,j1,j2:integer;
begin
assign(input,'palin.in');
assign(output,'palin.out');
reset(input);
rewrite(output);
readln(n);
for j1:=1 to n do
begin
read(a[j1]);
b[n-j1+1]:=a[j1];
end;
max[1,1]:=1;
max[1,0]:=0;
max[0,1]:=0;
for j1:=1 to n do
for j2:=1 to n do
begin
if a[j1]=b[j2] then max[j1,j2]:=max[j1-1,j2-1]+1
else if max[j1-1,j2]>max[j1,j2-1] then max[j1,j2]:=max[j1-1,j2] else max[j1,j2]:=max[j1,j2-1];
end;
writeln(n-max[n,n]);
close(input);
close(output);
end.