n,m = map(int,input().split())
lr = [list(map(int,input().split()))for i in range(m)]

low = 1
high = 10**5

for l,r in lr:
    if low <= l:
        low = l 
    if r <= high:
        high = r 

if high < low:
    print(0)
    exit()
print(high - low + 1) 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 i in range(m) for i in range(m) i range(m) range m for i 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 i in range(m)] lr [list(map(int,input().split()))for i in range(m)] low = 1 low 1 high = 10**5 high 10**5 10 5 for l,r in lr:
    if low <= l:
        low = l 
    if r <= high:
        high = r  l r lr if low <= l:
        low = l 
     low <= l low l low = l low l if r <= high:
        high = r  r <= high r high high = r high r if high < low:
    print(0)
    exit() high < low high low print(0) print 0 exit() exit print(high - low + 1) print high - low + 1 high - low high low 1 lr = [list(map(int,input().split()))for i in range(m)] [list(map(int,input().split()))for i in range(m)] lr low = l l low high = 10**5 10**5 high low = 1 1 low m = map(int,input().split()) map(int,input().split()) m n,m = map(int,input().split()) map(int,input().split()) n high = r r high
n,m = map(int,input().split())
lr = [list(map(int,input().split()))for i in range(m)]

low = 1
high = 10**5

for l,r in lr:
    if low <= l:
        low = l 
    if r <= high:
        high = r 

if high < low:
    print(0)
    exit()
print(high - low + 1)