program ABC166C
    implicit none
    integer n,k,j(2),l,c
    integer,allocatable::a(:),b(:)
    read(*,*) n,k
    allocate(a(n),b(n))
    b=0
    read(*,*) a(1:n)
    do k=1,n-1
        read(*,*) j(1:2)
        if(a(j(1))>a(j(2))) b(j(2))=b(j(2))+1
        if(a(j(2))>a(j(1))) b(j(1))=b(j(1))+1
    end do
    c=0
    do l=1,n
        if(b(l)==0) c=c+1
    end do
    write(*,*) c
end program ABC166C