program prob4
    implicit none
    integer :: N
    integer, allocatable :: A(:)
    integer :: i
    integer :: ans, mode
    read(*,*) N
    allocate(A(N))
    read(*,*) A

    ans = 1
    mode = 0 !0:未定 1:増加 2:減少

    do i = 2, N
        if(A(i) == A(i-1)) then
            cycle
        else if(A(i) > A(i-1)) then
            if(mode == 0) then
                mode = 1
            else if(mode == 1) then
                mode = 1
            else 
                ans = ans + 1
                mode = 0
            end if
        else
            if(mode == 0) then
                mode = 2
            else if(mode == 1) then
                ans = ans + 1
                mode = 0
            else 
                ans = ans + 1
                mode = 2
            end if            
        end if

    end do
    write(*,*) ans

    deallocate(A)

    stop
contains
end program prob4