a, b = gets.split.map(&:to_i)
l, m = [], []
b.times do
  x, y = gets.chop.split.map(&:to_i)
  l << x
  m << y
end

duplicated_array = [l + m].flatten!
answer_array = [l + m].flatten!

b.times do |n|
  gate = [l[n-1..b-1] + m[0..n-1]].flatten!
  duplicated_array.each do |w|
    answer_array.delete(w) unless gate.include?(w)
  end
end

a = []

answer_array.each do |w|
  a << w unless a.include?(w)
end

puts a.count