### main

n, m = gets.split.map(&:to_i)

sum = n + 1

if m > 0
  rngs = Array.new(m){gets.split.map(&:to_i)}.sort
  #p rngs

  l0, r0 = rngs[0]
  for i in (1...m)
    l1, r1 = rngs[i]
    if r0 < l1
      sum += (r0 - l0) * 2
      l0 = l1
      r0 = r1
    else
      r0 = r1 if r0 < r1
    end
  end
  sum += (r0 - l0) * 2
end

puts sum