k, g = list(map(int, input().split()))
id = [list(map(int, input().split())) for i in range(g)]
l, r = list(zip(*id))
print(min(r) - max(l) + 1) if min(r) - max(l) >= 0 else print(0) k, g = list(map(int, input().split())) k list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split g list(map(int, input().split())) for i in range(g) for i in range(g) i range(g) range g for i in range(g) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split id = [list(map(int, input().split())) for i in range(g)] id [list(map(int, input().split())) for i in range(g)] l, r = list(zip(*id)) l list(zip(*id)) list zip(*id) zip *id id r print(min(r) - max(l) + 1) if min(r) - max(l) >= 0 else print(0) min(r) - max(l) >= 0 min(r) - max(l) min(r) min r max(l) max l 0 print(min(r) - max(l) + 1) print min(r) - max(l) + 1 min(r) - max(l) min(r) min r max(l) max l 1 print(0) print 0 l, r = list(zip(*id)) list(zip(*id)) l g = list(map(int, input().split())) list(map(int, input().split())) g r = list(zip(*id)) list(zip(*id)) r k, g = list(map(int, input().split())) list(map(int, input().split())) k id = [list(map(int, input().split())) for i in range(g)] [list(map(int, input().split())) for i in range(g)] id
k, g = list(map(int, input().split()))
id = [list(map(int, input().split())) for i in range(g)]
l, r = list(zip(*id))
print(min(r) - max(l) + 1) if min(r) - max(l) >= 0 else print(0)
