n, m = map(int, input().split())
l_list, r_list = [], []

for i in range(m):
	l, r = map(int, input().split())
	l_list.append(l)
	r_list.append(r)

limit_min = max(l_list)
limit_max = min(r_list)
cnt = 0

for i in range(1, n + 1):
	if limit_min <= i <= limit_max:
		cnt += 1

print(cnt) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m l_list, r_list = [], [] l_list [] r_list [] for i in range(m):
	l, r = map(int, input().split())
	l_list.append(l)
	r_list.append(r) i range(m) range m l, r = map(int, input().split()) l map(int, input().split()) map int input().split() ().split () input split r l_list.append(l) l_list.append l_list append l r_list.append(r) r_list.append r_list append r limit_min = max(l_list) limit_min max(l_list) max l_list limit_max = min(r_list) limit_max min(r_list) min r_list cnt = 0 cnt 0 for i in range(1, n + 1):
	if limit_min <= i <= limit_max:
		cnt += 1 i range(1, n + 1) range 1 n + 1 n 1 if limit_min <= i <= limit_max:
		cnt += 1 limit_min <= i <= limit_max limit_min <= i limit_min i limit_max cnt += 1 cnt 1 print(cnt) print cnt m = map(int, input().split()) map(int, input().split()) m l, r = map(int, input().split()) map(int, input().split()) l limit_max = min(r_list) min(r_list) limit_max cnt = 0 0 cnt r = map(int, input().split()) map(int, input().split()) r cnt += 1 1 cnt n, m = map(int, input().split()) map(int, input().split()) n l_list, r_list = [], [] [] l_list limit_min = max(l_list) max(l_list) limit_min r_list = [], [] [] r_list
n, m = map(int, input().split())
l_list, r_list = [], []

for i in range(m):
	l, r = map(int, input().split())
	l_list.append(l)
	r_list.append(r)

limit_min = max(l_list)
limit_max = min(r_list)
cnt = 0

for i in range(1, n + 1):
	if limit_min <= i <= limit_max:
		cnt += 1

print(cnt)
