      PROGRAM piyo
      use stackMod
      IMPLICIT NONE
      integer,parameter :: prec = 4
      integer(prec) :: n,m
      integer(prec),allocatable :: h(:),a(:),b(:)
      integer(prec) :: i,k,ans
      logical,allocatable :: good(:)
      
      read*,n,m
      allocate( h(n), a(m),b(m) )
      allocate( good(n) )
      good = .true.
      read*,h(1:n)
      
      do i = 1,m
        read*,a(i),b(i)
      end do
      
      
      do i = 1,m
        
        if( h(a(i)) > h(b(i)) )then
          good(b(i)) = .false.
        else if( h(a(i))<h(b(i)) )then
          good(a(i)) = .false.
        else
          good(a(i)) = .false.
          good(b(i)) = .false.
        end if
      end do
      
      ans = count( good )
      print*,ans
      
      END PROGRAM