fun main() {
    val m = readLine()!!.split(' ')[1].toInt()
    val hs = readLine()!!.split(' ').map { it.toInt() to true }.toMutableList()
    repeat(m) {
        val input = readLine()!!.split(' ').map { it.toInt() }
        val l = input[0] - 1
        val r = input[1] - 1
        val lh = hs[l].first
        val rh = hs[r].first
        if (lh == rh) {
            hs[l] = hs[l].copy(second = false)
            hs[r] = hs[r].copy(second = false)
            return@repeat
        }
        val index = if (lh < rh) l else r
        hs[index] = hs[index].copy(second = false)
    }

    println(hs.count { it.second })
}