program coolboy;
var n,c1,c2,c3,i,max:longint;
a,b:array[1..35000]of longint;
begin
assign(input,'officer.in');reset(input);
assign(output,'officer.out');rewrite(output);
read(n);
for i:=1 to n do
begin
read(a[i]);
if a[i]=1 then begin b[i]:=c1+1;c1:=b[i];end;
if a[i]=2 then
begin
if c1>c2 then begin b[i]:=c1+1;c2:=b[i] end
else begin b[i]:=c2+1;c2:=b[i];end;
end;
if a[i]=3 then
begin
if c1>c2 then
begin
if c1>c3 then begin b[i]:=c1+1;c3:=b[i];end
else begin b[i]:=c3+1;c3:=b[i];end;
end
else
begin
if c2>c3 then begin b[i]:=c2+1;c3:=b[i];end
else begin b[i]:=c3+1;c3:=b[i];end;
end;
end;
end;
max:=0;
for i:=1 to n do if b[i]>max then max:=b[i];
for i:=1 to n do b[i]:=0;c1:=0;c2:=0;c3:=0;
for i:=n downto 1 do
begin
if a[i]=1 then begin b[i]:=c1+1;c1:=b[i];end;
if a[i]=2 then
begin
if c1>c2 then begin b[i]:=c1+1;c2:=b[i] end
else begin b[i]:=c2+1;c2:=b[i];end;
end;
if a[i]=3 then
begin
if c1>c2 then
begin
if c1>c3 then begin b[i]:=c1+1;c3:=b[i];end
else begin b[i]:=c3+1;c3:=b[i];end;
end
else
begin
if c2>c3 then begin b[i]:=c2+1;c3:=b[i];end
else begin b[i]:=c3+1;c3:=b[i];end;
end;
end;
end;
for i:=1 to n do if b[i]>max then max:=b[i];
writeln(n-max);
close(input);
close(output);
end.