program palin(input,output);
var
i,j,k:longint;
n:longint;
ans:longint;
a:array [0..5001,0..5001] of longint;
z,d:array [1..5000] of char;
function max(x,y:longint):longint;
begin
if x>y then max:=x
else max:=y;
end;
begin
assign(input,'palin.in');
assign(output,'palin.out');
reset(input);
rewrite(output);
readln(n);
for i := 1 to n do
read(z[i]);
readln;
k:=n;
for j:=1 to n do begin
d[j]:=z[k];
k:=k-1;
end;
a[0,0]:=0;
for i:=1 to n do
for j:=1 to n do
begin
if z[i]=d[j] then a[i,j]:=a[i-1,j-1]+1;
if z[i]<>d[j] then a[i,j]:=max(a[i-1,j],a[i,j-1]);
end;
ans:=n-a[n,n];
writeln(ans);
close(input);
close(output);
end.