import scala.io.StdIn._

object Helpers {
  def readIntLine = readLine.split(" ").map(_.toInt)
  def readInts(n: Int) = Array.fill(n)(readInt)

  def splitDigits(i: Int): Seq[Int] = i.toString.map(_.asDigit)

  def log[A](x: A): A = {println(x); x}

  implicit class IntImplicits(val i: Int) {
    def isEven = i % 2 == 0
    def isOdd = !isEven
  }
}

object Main extends App {
  import Helpers._

  val Array(n, m) = readIntLine
  val hs: Array[Int] = readIntLine

  var roads = Map[Int, Set[Int]]()
  for (_ <- Range(0, m)) {
    val Array(a, b) = readIntLine
    roads = if (roads.contains(a)) roads + (a -> (roads(a) + b)) else roads + (a -> Set(b))
    roads = if (roads.contains(b)) roads + (b -> (roads(b) + a)) else roads + (b -> Set(a))
  }

  def isGood(x: Int, roads: Map[Int, Set[Int]]): Boolean = {
    if (roads.contains(x + 1)) {
      val h = hs(x)
      !roads(x + 1).exists((a: Int) => (hs(a - 1) >= h))
    } else {
      true
    }
  }

  println(Range(0, n).count(isGood(_, roads)))
}

