n, m = map(int, input().split())
 
max_left = 1
min_right = n
 
for i in range(m):
    left, right = map(int, input().split())
    max_left = max(max_left, left)
    min_right = min(min_right, right)
 
print(max(min_right - max_left + 1, 0)) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m max_left = 1 max_left 1 min_right = n min_right n for i in range(m):
    left, right = map(int, input().split())
    max_left = max(max_left, left)
    min_right = min(min_right, right)
  i range(m) range m left, right = map(int, input().split()) left map(int, input().split()) map int input().split() ().split () input split right max_left = max(max_left, left) max_left max(max_left, left) max max_left left min_right = min(min_right, right) min_right min(min_right, right) min min_right right print(max(min_right - max_left + 1, 0)) print max(min_right - max_left + 1, 0) max min_right - max_left + 1 min_right - max_left min_right max_left 1 0 right = map(int, input().split()) map(int, input().split()) right left, right = map(int, input().split()) map(int, input().split()) left max_left = 1 1 max_left n, m = map(int, input().split()) map(int, input().split()) n min_right = n n min_right max_left = max(max_left, left) max(max_left, left) max_left min_right = min(min_right, right) min(min_right, right) min_right m = map(int, input().split()) map(int, input().split()) m
n, m = map(int, input().split())
 
max_left = 1
min_right = n
 
for i in range(m):
    left, right = map(int, input().split())
    max_left = max(max_left, left)
    min_right = min(min_right, right)
 
print(max(min_right - max_left + 1, 0))