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

    ans = 1
    p = 0
    cnt = 0
    do i = 2, N
        if(p == 0) then
            if(A(i) > A(i-1)) then
                p = 1
                cnt = 1
            else if(A(i) < A(i-1)) then
                p = -1
                cnt = 1
            end if
        else
            if(p == 1) then
                if(A(i) < A(i-1)) then
                    p = 0
                    ans = ans + 1
                    cnt = 0
                end if
            else
                if(A(i) > A(i-1)) then
                    p = 0
                    ans = ans + 1
                    cnt = 0
                end if
            end if
        end if
    end do

    write(*,*) ans
    stop
end program