n,m = map(int,input().split())
lr= [list(map(int,input().split()))for a in range(m)]
l,r = [list(b) for b in zip(*lr)]
left,right = max(l),min(r)
cnt = 0
for i in range(1,n+1):
	if left <= i and i <= right:
		cnt += 1
print(cnt) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m list(map(int,input().split()))for a in range(m) for a in range(m) a range(m) range m for a in range(m) list(map(int,input().split())) list map(int,input().split()) map int input().split() ().split () input split lr= [list(map(int,input().split()))for a in range(m)] lr [list(map(int,input().split()))for a in range(m)] list(b) for b in zip(*lr) for b in zip(*lr) b zip(*lr) zip *lr lr for b in zip(*lr) list(b) list b l,r = [list(b) for b in zip(*lr)] l [list(b) for b in zip(*lr)] r left,right = max(l),min(r) left max(l) max l right min(r) min r cnt = 0 cnt 0 for i in range(1,n+1):
	if left <= i and i <= right:
		cnt += 1 i range(1,n+1) range 1 n+1 n 1 if left <= i and i <= right:
		cnt += 1 left <= i and i <= right left <= i left i i <= right i right cnt += 1 cnt 1 print(cnt) print cnt r = [list(b) for b in zip(*lr)] [list(b) for b in zip(*lr)] r l,r = [list(b) for b in zip(*lr)] [list(b) for b in zip(*lr)] l left,right = max(l),min(r) max(l) left right = max(l),min(r) min(r) right n,m = map(int,input().split()) map(int,input().split()) n cnt = 0 0 cnt lr= [list(map(int,input().split()))for a in range(m)] [list(map(int,input().split()))for a in range(m)] lr m = map(int,input().split()) map(int,input().split()) m cnt += 1 1 cnt
n,m = map(int,input().split())
lr= [list(map(int,input().split()))for a in range(m)]
l,r = [list(b) for b in zip(*lr)]
left,right = max(l),min(r)
cnt = 0
for i in range(1,n+1):
	if left <= i and i <= right:
		cnt += 1
print(cnt)