program sample
    implicit none
  
    integer(8) :: i,j,m,n,a0,a1,b,c,d
    integer(8),allocatable :: x(:),y(:)
  
    read(*,*) n
    if(n<3)then
        write(*,*)1
        stop
    end if
    allocate(x(n))
    read(*,*)x
    if (x(1)<x(2))then
        a0=1
    elseif (x(1)==x(2))then
        a0=0
    else
        a0=-1
    end if
    m=1
    b=0
    do i=2,n-1
        
        if (x(i)<x(i+1))then
            a1=1
        elseif (x(i)==x(i+1))then
           
            cycle
        else
            a1=-1
        end if
        if(b==0)then
            if(a0*a1<0)then
                m=m+1
                b=1
            end if
        else
            b=0
        end if
        a0=a1
        
        
    enddo
    write(*,*) m
  
    stop
end program sample
  

