program noip5_2;
var
s1,s2:array[1..5000] of char;
f:array[0..5000,0..5000] of integer;
n:integer;
procedure init;
var
i:integer;
begin
readln(n);
for i:=1 to n do
begin
read(s1[i]);
s2[n-i+1]:=s1[i]
end;
end;
procedure main;
var
i,j:integer;
begin
for i:=1 to n do
for j:=1 to n do
begin
f[i,j]:=f[i-1,j];
if f[i,j-1]>f[i,j]
then f[i,j]:=f[i,j-1];
if s1[i]=s2[j]
then if f[i-1,j-1]+1>f[i,j]
then f[i,j]:=f[i-1,j-1]+1;
end;
writeln(n-f[n,n]);
end;
begin
assign(input,'palin.in');
assign(output,'palin.out');
init;
main;
close(input); close(output);
end.