n,m = map(int,input().split())
lst_l = []
lst_r = []
for _ in range(m):
    l,r = map(int,input().split())
    lst_l.append(l)
    lst_r.append(r)

max_l = max(lst_l)
min_r = min(lst_r)

count = 0
for i in range(n):
    if max_l <= i+1 <= min_r:
        count += 1

print(count) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m lst_l = [] lst_l [] lst_r = [] lst_r [] for _ in range(m):
    l,r = map(int,input().split())
    lst_l.append(l)
    lst_r.append(r) _ range(m) range m l,r = map(int,input().split()) l map(int,input().split()) map int input().split() ().split () input split r lst_l.append(l) lst_l.append lst_l append l lst_r.append(r) lst_r.append lst_r append r max_l = max(lst_l) max_l max(lst_l) max lst_l min_r = min(lst_r) min_r min(lst_r) min lst_r count = 0 count 0 for i in range(n):
    if max_l <= i+1 <= min_r:
        count += 1 i range(n) range n if max_l <= i+1 <= min_r:
        count += 1 max_l <= i+1 <= min_r max_l <= i+1 max_l i+1 i 1 min_r count += 1 count 1 print(count) print count lst_l = [] [] lst_l m = map(int,input().split()) map(int,input().split()) m lst_r = [] [] lst_r n,m = map(int,input().split()) map(int,input().split()) n l,r = map(int,input().split()) map(int,input().split()) l count = 0 0 count r = map(int,input().split()) map(int,input().split()) r count += 1 1 count min_r = min(lst_r) min(lst_r) min_r max_l = max(lst_l) max(lst_l) max_l
n,m = map(int,input().split())
lst_l = []
lst_r = []
for _ in range(m):
    l,r = map(int,input().split())
    lst_l.append(l)
    lst_r.append(r)

max_l = max(lst_l)
min_r = min(lst_r)

count = 0
for i in range(n):
    if max_l <= i+1 <= min_r:
        count += 1

print(count)