program peaks

 implicit none
 integer::n,m,i,j,answer,hikaku
 integer(8),allocatable::h(:),a(:),b(:),ans(:)

 read*,n,m
 allocate(h(0:n),a(m),b(m),ans(n))
  
 h(0)=-1
 read*,h(1:n)
 !print*,h
 do i=1,m
  read*,a(i),b(i)
  !print*,a(i),b(i)
 end do

 ans=0
 answer=0
  
  do i=1,n
   do j=1,m 
   if(i==a(j)) hikaku=b(j)
   if(i==b(j)) hikaku=a(j)
   if(i/=a(j) .and. i/=b(j)) hikaku=0
    if(h(i)<=h(hikaku)) then
    ans(i)=ans(i)+1
    end if  
   end do
   if(ans(i)==0) answer=answer+1
  end do

  print*,answer

end program peaks