fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val h = Array(100010) { 0 }
    val ma = Array(100010) { 0 }

    readLine()!!.split(' ').map { it.toInt() }.forEachIndexed { index, i ->
        h[index + 1] = i
    }

    (0 until m).forEachIndexed { index, i ->
        val (a, b) = readLine()!!.split(' ').map { it.toInt() }
        ma[a] = Math.max(ma[a], h[b])
        ma[b] = Math.max(ma[b], h[a])
    }

    var ans = 0

    (0..n).forEachIndexed { index, i ->
        if (h[i] > ma[i]) {
            ans++
        }
    }

    println(ans)
}
