program jiji
implicit none
integer :: n, i, j, nstat, c
integer,allocatable :: a(:)

read(*,*) n
allocate(a(n))
read(*,*) a
j = 1

do while ( a(j) == a(j+1) )
	j = j + 1
end do

if ( a(j) > a(j+1) ) then
	nstat = -1
else
    nstat = 1
end if

c = 1
do i = j+1, n-1
	if ( nstat == -1 ) then
		if ( a(i) < a(i+1) ) then
        	c = c + 1
    		nstat = 0
        end if
    else if ( nstat == 1 ) then
    	if ( a(i) > a(i+1) ) then
        	c = c + 1
            nstat = 0
        end if
    else if ( nstat == 0 ) then
    	if ( a(i) > a(i+1) ) then
			nstat = -1
		else if ( a(i) < a(i+1) ) then
 		   nstat = 1
		end if
    end if
end do

write(*,*) c
stop
end program jiji