n,m = map(int,input().split())
l = 0
r = n
for i in range(m):
    li,ri = map(int, input().split())
    l = max(l,li)
    r = min(r,ri)
if r < l:
    ans = 0
else:
    ans = r - l + 1
print(ans) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m l = 0 l 0 r = n r n for i in range(m):
    li,ri = map(int, input().split())
    l = max(l,li)
    r = min(r,ri) i range(m) range m li,ri = map(int, input().split()) li map(int, input().split()) map int input().split() ().split () input split ri l = max(l,li) l max(l,li) max l li r = min(r,ri) r min(r,ri) min r ri if r < l:
    ans = 0
else:
    ans = r - l + 1 r < l r l ans = 0 ans 0 ans = r - l + 1 ans r - l + 1 r - l r l 1 print(ans) print ans l = 0 0 l ri = map(int, input().split()) map(int, input().split()) ri l = max(l,li) max(l,li) l n,m = map(int,input().split()) map(int,input().split()) n ans = 0 0 ans r = n n r r = min(r,ri) min(r,ri) r m = map(int,input().split()) map(int,input().split()) m li,ri = map(int, input().split()) map(int, input().split()) li ans = r - l + 1 r - l + 1 ans
n,m = map(int,input().split())
l = 0
r = n
for i in range(m):
    li,ri = map(int, input().split())
    l = max(l,li)
    r = min(r,ri)
if r < l:
    ans = 0
else:
    ans = r - l + 1
print(ans)