N, M = gets.split.map(&:to_i)
LRs = readlines.map{|l| l.split.map(&:to_i)}

puts LRs.each_with_object(Array.new(N + 2, 0)){|(l, r), a| a[l] += 1; a[r + 1] -= 1}.inject([]){|b, a| b << (b.last || 0) + a}.count(M)