import Foundation

let input_line: String = readLine()!
let split: [String] = input_line.components(separatedBy: " ")

let n = Int(split[0])!
let m = Int(split[1])!

var nArray: [Int] = []
var mArray: [[Int]] = []

let input_line2: String = readLine()!
let split2: [String] = input_line2.components(separatedBy: " ")
for i in 0..<n {
    nArray.append(Int(split2[i])!)
}

for _ in 0..<m {
    let input_line3: String = readLine()!
    let split3: [String] = input_line3.components(separatedBy: " ")
    let array = [Int(split3[0])!, Int(split3[1])!]
    mArray.append(array)
}

var ans = 0

for i in 1...n {
    var max = 0
    for road in mArray {
        if road.contains(i) {
            let a = nArray[road[0]]
            let b = nArray[road[1]]
            if a > b {
                max = road[0]
            } else {
                max = road[1]
            }
        }
    }
    if max == i {
        ans += 1
    }
}

print(ans)