defmodule Main do
  def main do
    [n, m] = 
      IO.gets("")
      |> String.trim()
      |> String.split()
      |> Enum.map(&String.to_integer/1)
      #|> IO.inspect()
      
    h = 
      IO.gets("")
      |> String.trim()
      |> String.split()
      |> Enum.map(&String.to_integer/1)
      #|> IO.inspect()
    a =  
      IO.stream(:stdio, :line) 
      |> Enum.take(m) 
      |> Enum.map(&String.trim(&1)) 
      |> Enum.map(&String.split(&1)) 
      |> Enum.map(&Enum.map(&1, fn str -> String.to_integer(str) end))
	  #|> IO.inspect()
    acc = Enum.map(1..n, fn x -> x end)  
	solve(a, h, acc)
    |> IO.puts()
  end
  
  def solve([], _, acc), do: acc |> Enum.count()
#  def solve([[a, b] | tail], h, acc) when a in acc do
  def solve([[a, b] = head | tail], h, acc) do
    #IO.inspect(head, label: :head)
    #IO.inspect(acc, label: :acc)
    cond do
      a not in acc ->
        solve(tail, h, acc)
      Enum.at(h, a - 1) > Enum.at(h, b - 1) ->
        solve(tail, h, Enum.reject(acc, fn x -> x == b end))
      Enum.at(h, a - 1) < Enum.at(h, b - 1) ->
        solve(tail, h, Enum.reject(acc, fn x -> x == a end))
      true ->
        solve(tail, h, Enum.reject(acc, fn x -> x in head end))
    end
  end
  
  def solve([_ | tail], h, acc), do: solve(tail, h, acc)
end
    