object Main extends App {

  val sc = new java.util.Scanner(System.in) 
  val n, m = sc.nextInt()
  val g = Array.fill(m)((sc.nextInt() to sc.nextInt()).toSet)
  val ans = g.foldLeft((1 to n).toSet)((x, y) => x & y)
  println(ans)
}