n,m = gets.split.map &:to_i
arr = Array.new(m)
m.times do |i|
  arr[i] = gets.split.map &:to_i
end
check = Array.new(n, 1)
m.times do |i|
  (arr[i][0]-1).times do |j|
    check[j] = 0
  end
  (n - arr[i][1]).times do |j|
    check[-(j+1)] = 0
  end
end
puts check.count(1)