n,m = map(int,input().split())
l = 0
r = n+2
for i in range(m):
    a,b = map(int,input().split())
    l = max(l,a)
    r = min(r,b)
print(max(r-l+1,0)) 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+2 r n+2 n 2 for i in range(m):
    a,b = map(int,input().split())
    l = max(l,a)
    r = min(r,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 = max(l,a) l max(l,a) max l a r = min(r,b) r min(r,b) min r b print(max(r-l+1,0)) print max(r-l+1,0) max r-l+1 r-l r l 1 0 n,m = map(int,input().split()) map(int,input().split()) n a,b = map(int,input().split()) map(int,input().split()) a r = n+2 n+2 r m = map(int,input().split()) map(int,input().split()) m l = max(l,a) max(l,a) l b = map(int,input().split()) map(int,input().split()) b l = 0 0 l r = min(r,b) min(r,b) r
n,m = map(int,input().split())
l = 0
r = n+2
for i in range(m):
    a,b = map(int,input().split())
    l = max(l,a)
    r = min(r,b)
print(max(r-l+1,0))
