program zigzag;
var i,n,s1,s2,x1,x2,first,second:longint;
    f:text;
function min(x,y:longint):longint;
begin
if x<y
   then min:=x
   else min:=y;
end;

begin
read(n);
read(first,second);
if second>first
   then begin
        s1:=0;
        s2:=1;
        end;
if second<first
   then begin
        s1:=1;
        s2:=0;
        end;
if second=first
   then begin
        s1:=1;
        s2:=1;
        end;
for i:=3 to n do
    begin
    first:=second;
    read({f,}second);
    if second>first
       then begin
            x1:=min(s1+1,s2);
            x2:=min(s1+2,s2+1);
            end;
    if second<first
       then begin
            x1:=min(s1+1,s2+2);
            x2:=min(s1,s2+1);
            end;
    if second=first
       then begin
            x1:=min(s1+1,s2+2);
            x2:=min(s1+2,s2+1);
            end;
    s1:=x1;
    s2:=x2;
    end;
writeln(min(s1,s2));
end.