program cch(input,output);
var
i,n,ans,j:integer;
a,b:array[1..5000] of char;
f:array[0..5000,0..5000] of integer;
function max(x,y:integer):integer;
begin
if x>y then exit(x)
else exit(y);
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]);
for i:=1 to n do
b[i]:=a[n-i+1];
f[0,0]:=0; f[0,1]:=0; f[1,0]:=0;
for i:=1 to n do
for j:=1 to n do
if a[i]=b[j] then f[i,j]:=f[i-1,j-1]+1
else f[i,j]:=max(f[i,j-1],f[i-1,j]);
ans:=n-f[n,n];
write(ans);
close(input);
close(output);
end.