n, m = gets.split.map(&:to_i)
cd = m.times.map{gets.split.map(&:to_i)}
b = Array.new(n+1, false)
cd.each do |cc|
    cc[0].upto(cc[1]-1) do |i|
        b[i] = true
    end
end
p b.count{|bl| bl} * 2 + n + 1