N, M = map(int, input().split())
l = []
r = []
for i in range(M):
    L, R = map(int, input().split())
    l.append(L)
    r.append(R)
m = min(r) - max(l)
if m < 0:
    print(0)
else:
    print(m + 1) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M l = [] l [] r = [] r [] for i in range(M):
    L, R = map(int, input().split())
    l.append(L)
    r.append(R) i range(M) range M L, R = map(int, input().split()) L map(int, input().split()) map int input().split() ().split () input split R l.append(L) l.append l append L r.append(R) r.append r append R m = min(r) - max(l) m min(r) - max(l) min(r) min r max(l) max l if m < 0:
    print(0)
else:
    print(m + 1) m < 0 m 0 print(0) print 0 print(m + 1) print m + 1 m 1 N, M = map(int, input().split()) map(int, input().split()) N M = map(int, input().split()) map(int, input().split()) M L, R = map(int, input().split()) map(int, input().split()) L r = [] [] r l = [] [] l R = map(int, input().split()) map(int, input().split()) R m = min(r) - max(l) min(r) - max(l) m
N, M = map(int, input().split())
l = []
r = []
for i in range(M):
    L, R = map(int, input().split())
    l.append(L)
    r.append(R)
m = min(r) - max(l)
if m < 0:
    print(0)
else:
    print(m + 1)