import Foundation

func isHeightest(number: Int, array: [Int], heights: [Int]) -> Bool {
    if array.isEmpty {
      return true
    }
  
    var c: [Int] = []
    
    
    for a in array {
        c.append(heights[a-1])
    }
        
    if c.max()! == c.min()! {
        return false
    }

    
    let heighest = c.max()!
    
    if heighest == c.min()! {
        return false
    }
    
    if heighest == heights[number] {
        return true
    } else {
        return false
    }
}

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

var newArray: [[Int]] = []
for i in 0..<n {
    var array: [Int] = []
    for road in mArray {
        if road.contains(i) {
            array += road
        }
    }
    if isHeightest(number: i, array: array, heights: nArray) {
        ans += 1
    }
    
}


print(ans)