val sees: MutableSet<Int> = mutableSetOf()
val paths: MutableMap<Int, MutableList<Int>> = mutableMapOf()

fun main(args: Array<String>) {
    val line = readLine()!!.trim()
    val (n, m) = line.split(" ").map {it.toInt()}
    val hights: List<Int> = readLine()!!.trim().split(" ").map {it.toInt()}.take(n)

    (0..n).forEach {
        paths.put(it, mutableListOf())
    }

    (0..m-1).forEach {
        val (a, b) = readLine()!!.trim().split(" ").map {it.toInt()}
        paths[a - 1]!!.add(b - 1)
        paths[b - 1]!!.add(a - 1)
    }

    var yoiCount: Int = 0

    for (i in (0..n-1)) {
        // if (sees.contains(i)) {
        //     continue
        // }
        var hightGroup: MutableList<Int> = mutableListOf()

        hightGroup.add(hights[i])
        sees.add(i)
        var node: Int = i

        search(node, hightGroup, hights)

        val maxHeight = hightGroup.max()
        // println("${hightGroup} ${maxHeight}, ${hightGroup.filter {it == maxHeight}.size}")
        if (maxHeight == hights[i] && hightGroup.filter {it == maxHeight}.size == 1) {
            yoiCount += 1
        }
    }


    println("${yoiCount}")
}

fun search(node: Int, hightGroup: MutableList<Int>, hights: List<Int>) {

    var distinations: List<Int> = paths[node]!!

    for (nextNode in distinations) {
        // if (sees.contains(nextNode)) {
        //     continue
        // }

        hightGroup.add(hights[nextNode])
        sees.add(nextNode)

        // search(nextNode, hightGroup, hights)
    }
}