program problemC
  implicit none

integer :: NMAX,MMAX,count
integer, allocatable :: H(:),A(:),B(:),fail(:),mat(:,:)
integer :: n,m,k,l,j,i,c,dekka


read(*,*) NMAX, MMAX

dekka=max(NMAX,MMAX)

allocate(H(NMAX),A(MMAX),B(MMAX),fail(NMAX),mat(dekka,dekka))


  mat(:,:)=1


read(*,*) H(:)
do m=1,MMAX
  read(*,*) A(m),B(m)
  mat(A(m),B(m))=0
  mat(B(m),A(m))=0
end do


count=0
do n=1,dekka
  do k=1,dekka
    if (mat(n,k)==0) then
      if (H(n)<=H(k)) then
        count=count+1
        exit
      end if
    end if
  end do
end do





! do while (A(m)==n)
!   if (H(B(m))>H(n)) then
!     fail(n)=0
!     exit
!   end if
!   m=m+1
! end do

write(*,*) NMAX-count

deallocate(H,A,B,fail,mat)


stop
contains
  subroutine heapsort(n,array)
    implicit none
    integer,intent(in) :: n
    integer,intent(inout) :: array(1:n)

    integer ::i,k,j,l
    double precision :: t

    if(n.le.0)then
       write(6,*)"Error, at heapsort"; stop
    endif
    if(n.eq.1) return

   !stop
    l=n/2+1
    k=n
    do while(k.ne.1)
       if(l.gt.1)then
          l=l-1
          t=array(l)
       else
          t=array(k)
          array(k)=array(1)
          k=k-1
          if(k.eq.1) then
             array(1)=t
             exit
          endif
       endif
       i=l
       j=l+l
       !stop
       do while(j.le.k)
          if(j.lt.k)then
             if(array(j).lt.array(j+1))j=j+1
          endif
          if (t.lt.array(j))then
             array(i)=array(j)
             i=j
             j=j+j
          else
             j=k+1
          endif
       enddo
       array(i)=t

    enddo
  end subroutine heapsort

  subroutine swap(a,b)
    implicit none

    integer, intent(inout) :: a, b
    integer :: c, d


      c=a
      d=b
      a=d
      b=c

  end subroutine swap

end program
