fun main(args: Array<String>) {

    val inputCount = readLine()!!.split(" ").map { it.toInt() }

    val observatoryCount = inputCount[0]
    val pathCount = inputCount[1]

    val observatories = readLine()!!.split(" ").map { it.toInt() }.map{ Observatory(it) }

    repeat(pathCount) {
        val pathInput = readLine()!!.split(" ").map { it.toInt() }
        val a = pathInput[0]
        val b = pathInput[1]

        observatories[a-1].addPath(observatories[b-1])
        observatories[b-1].addPath(observatories[a-1])
    }

    print(observatories.count { it.isGoodObservatory() })
}

class Observatory(val elevation: Int) {
    var neighbors = mutableListOf<Observatory>()

    fun addPath(obs: Observatory) {
        neighbors.add(obs)
    }

    fun isGoodObservatory(): Boolean {
        if(neighbors.size == 0) {
            return true
        }
        neighbors.forEach {
            if(elevation <= it.elevation) {
                return false
            }
        }
        return true
    }
}