object Main extends App {
  import scala.io.StdIn._
  
  val Array(n,m) = readLine.split(" ").map{_.toInt}.toArray
  val h = readLine.split(" ").map{_.toLong}.toList
  val ab = (for (i <- 1 to m) yield {
    val Array(a,b) = readLine.split(" ").map{_.toInt}.toArray
    (a,b)
  }).toList
  
  val sortedH = h.zipWithIndex.sortWith((x,y) => x._1 > y._1).map{case (x,y) => (x,y+1)}
  val check = Array.fill(n+1)(false)
  check(0) = true
  var ans = 0
  
  for (x <- sortedH if check.count{x => !x} != 0) {
    val i = x._2
    if (!check(i)) {
      ans += 1
      check(i) = true
    }
    ab.filter{case (a,b) => a == i || b == i}.map{case (a,b) => if (a == i) b else a}.foreach{i => check(i) = true}
  }
 
  println(ans)
                                         
}