module agc81
 implicit none
contains
 function agc81a(h,a,b,x) result(ans)
  integer(8),intent(in)::h(:),a(:),b(:),x
  integer(8)::ia,ans
  do ia=1,size(a)
   if(a(ia)==h(x).and.h(x)<=b(ia))then
    ans=0
    return
   else if(b(ia)==h(x).and.h(x)<=a(ia))then
    ans=0
    return
   end if
  end do
  ans=1
 end function agc81a
end module agc81

program abc81
 use agc81
 implicit none
 integer(8)::N,M,ia,ib,ic,ans=0
 integer(8),allocatable::h(:),a(:),b(:)
 read(*,*)N,M
 allocate(h(N),a(M),b(M))
 read(*,*)(h(ia),ia=1,N)
 do ib=1,M
  read(*,*)a(ib),b(ib)
 end do
 do ic=1,N
  ans=ans+agc81a(h,a,b,ic)
 end do
 print'(i0)',ans
 deallocate(h,a,b)
end program abc81