module graph_mod
    implicit none
    type node
        integer(4),allocatable:: to(:)
        integer(4):: l
    end type
    
contains
    subroutine init(n)
        type(node):: n
        allocate(n%to(1))

        n%l = 0
    end subroutine


    subroutine regist(n,m)
        type(node):: n
        integer(4):: m

        if (n%l+1 > size(n%to)) call add_(n)
        n%l=n%l+1
        n%to(n%l) = m
    end subroutine


    subroutine add_(n)
        type(node):: n
        integer(4),allocatable:: tmp(:)
        integer(4):: l

        l = size(n%to)
        allocate(tmp(l))
        tmp(:) = n%to(:)
        deallocate(n%to)
        allocate(n%to(l*2))
        n%to(1:l) = tmp(:)
        deallocate(tmp)
    end subroutine
end module

program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,m,i,a,b,ans
    integer(int32), allocatable:: s(:),r(:)

    read*, n,m
    allocate(s(n),r(n))
    r(:) = 0
    read*, s(:)

    do i=1,m
        read*, a,b
        r(a) = max(r(a),s(b))
        r(b) = max(r(b),s(a))
    end do

    ans=0
    do i=1,n
        if (s(i) > r(i)) ans=ans+1
    end do
    print'(i0)', ans
end program name