output_description: Print the number of ID cards that allow us to pass all the gates alone.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N M
      L_1 R_1
      L_2 R_2
      \vdots
      L_M R_M
attempt: import sys
  from itertools import accumulate
  
  # booltable=[0]+booltable
  
  
  def resolve():
      input = sys.stdin.readline
      N, M = map(int, input().rstrip().split())
      G = [list(map(int, input().rstrip().split())) for _ in range(M)]
      l = [0 for _ in range(N)]
      for i in range(M):
          l[G[i][0] - 1] += 1
          if G[i][1] != N:
              l[G[i][1]] -= 1
      l = [0] + l
      cumsum = list(accumulate(l))  # 0~N
  
      ans = cumsum.count(int(M))
      print(ans)
  
  
  from io import StringIO
  import unittest
  
  
  class TestClass(unittest.TestCase):
      def assertIO(self, input, output):
          stdout, stdin = sys.stdout, sys.stdin
          sys.stdout, sys.stdin = StringIO(), StringIO(input)
          resolve()
          sys.stdout.seek(0)
          out = sys.stdout.read()[:-1]
          sys.stdout, sys.stdin = stdout, stdin
          self.assertEqual(out, output)
  
      def test_入力例_1(self):
          input = """4 2
  1 3
  2 4"""
          output = """2"""
          self.assertIO(input, output)
  
      def test_入力例_2(self):
          input = """10 3
  3 6
  5 7
  6 9"""
          output = """1"""
          self.assertIO(input, output)
  
      def test_入力例_3(self):
          input = """100000 1
  1 100000"""
          output = """100000"""
          self.assertIO(input, output)
  
  
  if __name__ == "__main__":
      # unittest.main()
      resolve()
  
problem_description: Statement
  
  We have N ID cards, and there are M gates.
  
  We can pass the i-th gate if we have one of the following ID cards: the L_i-
  th, (L_i+1)-th, ..., and R_i-th ID cards.
  
  How many of the ID cards allow us to pass all the gates alone?
samples: [{"input": "4 2\n    1 3\n    2 4", "output": "2\n    \n\nTwo ID cards allow us to pass all the gates alone, as follows:\n\n  * The first ID card does not allow us to pass the second gate.\n  * The second ID card allows us to pass all the gates.\n  * The third ID card allows us to pass all the gates.\n  * The fourth ID card does not allow us to pass the first gate.\n\n* * *"}, {"input": "10 3\n    3 6\n    5 7\n    6 9", "output": "1\n    \n\n* * *"}, {"input": "100000 1\n    1 100000", "output": "100000"}]