n,m = map(int,input().split())
lower = -float('inf')
upper = float('inf')
for i in range(m):
    l,r = map(int,input().split())
    if l > lower:
        lower = l
    if r < upper:
        upper = r
    if upper < lower:
        upper = 0
        lower = 0
        break
if upper == lower == 0:
    print(0)
else:
    print(upper - lower + 1) n,m = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split m lower = -float('inf') lower -float('inf') float('inf') float 'inf' upper = float('inf') upper float('inf') float 'inf' for i in range(m):
    l,r = map(int,input().split())
    if l > lower:
        lower = l
    if r < upper:
        upper = r
    if upper < lower:
        upper = 0
        lower = 0
        break i range(m) range m l,r = map(int,input().split()) l map(int,input().split()) map int input().split() ().split () input split r if l > lower:
        lower = l
     l > lower l lower lower = l lower l if r < upper:
        upper = r
     r < upper r upper upper = r upper r if upper < lower:
        upper = 0
        lower = 0
        break upper < lower upper lower upper = 0 upper 0 lower = 0 lower 0 break if upper == lower == 0:
    print(0)
else:
    print(upper - lower + 1) upper == lower == 0 upper == lower upper lower 0 print(0) print 0 print(upper - lower + 1) print upper - lower + 1 upper - lower upper lower 1 r = map(int,input().split()) map(int,input().split()) r upper = r r upper lower = l l lower lower = 0 0 lower n,m = map(int,input().split()) map(int,input().split()) n m = map(int,input().split()) map(int,input().split()) m lower = -float('inf') -float('inf') lower upper = 0 0 upper l,r = map(int,input().split()) map(int,input().split()) l upper = float('inf') float('inf') upper
n,m = map(int,input().split())
lower = -float('inf')
upper = float('inf')
for i in range(m):
    l,r = map(int,input().split())
    if l > lower:
        lower = l
    if r < upper:
        upper = r
    if upper < lower:
        upper = 0
        lower = 0
        break
if upper == lower == 0:
    print(0)
else:
    print(upper - lower + 1)