import java.util.Scanner

import scala.annotation.tailrec

object Main {
  def main(args: Array[String]) = {
    val sc = new Scanner(System.in)
    val N, M = sc.nextInt()
    val l = List.fill(M, 2)(sc.nextInt)

    val List(left, right) = l.transpose
    val r = left.max - right.min + 1


    println(r)

  }
}