n,m=map(int,input().split())
l,r=[],[]
for i in range(m):
    a,b=map(int,input().split())
    l.append(a)
    r.append(b)
s=0
t=n+1
for i in range(m):
    if l[i]>s:
        s=l[i]
    if r[i]<t:
        t=r[i]
if s>t:
    print(0)
else:
    print(t-s+1) n,m=map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m l,r=[],[] l [] r [] for i in range(m):
    a,b=map(int,input().split())
    l.append(a)
    r.append(b) i range(m) range m a,b=map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b l.append(a) l.append l append a r.append(b) r.append r append b s=0 s 0 t=n+1 t n+1 n 1 for i in range(m):
    if l[i]>s:
        s=l[i]
    if r[i]<t:
        t=r[i] i range(m) range m if l[i]>s:
        s=l[i]
     l[i]>s l[i] l i s s=l[i] s l[i] l i if r[i]<t:
        t=r[i] r[i]<t r[i] r i t t=r[i] t r[i] r i if s>t:
    print(0)
else:
    print(t-s+1) s>t s t print(0) print 0 print(t-s+1) print t-s+1 t-s t s 1 r=[],[] [] r l,r=[],[] [] l t=n+1 n+1 t m=map(int,input().split()) map(int,input().split()) m b=map(int,input().split()) map(int,input().split()) b t=r[i] r[i] t s=0 0 s a,b=map(int,input().split()) map(int,input().split()) a s=l[i] l[i] s n,m=map(int,input().split()) map(int,input().split()) n
n,m=map(int,input().split())
l,r=[],[]
for i in range(m):
    a,b=map(int,input().split())
    l.append(a)
    r.append(b)
s=0
t=n+1
for i in range(m):
    if l[i]>s:
        s=l[i]
    if r[i]<t:
        t=r[i]
if s>t:
    print(0)
else:
    print(t-s+1)