n, m = map(int, input().split())
a = 0; b = n+1
for _ in range(m):
    l, r = map(int, input().split())
    a = max(a, l)
    b = min(b, r)
print(max(0, b-a+1)) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m a = 0 a 0 b = n+1 b n+1 n 1 for _ in range(m):
    l, r = map(int, input().split())
    a = max(a, l)
    b = min(b, r) _ range(m) range m l, r = map(int, input().split()) l map(int, input().split()) map int input().split() ().split () input split r a = max(a, l) a max(a, l) max a l b = min(b, r) b min(b, r) min b r print(max(0, b-a+1)) print max(0, b-a+1) max 0 b-a+1 b-a b a 1 m = map(int, input().split()) map(int, input().split()) m a = max(a, l) max(a, l) a l, r = map(int, input().split()) map(int, input().split()) l b = min(b, r) min(b, r) b r = map(int, input().split()) map(int, input().split()) r b = n+1 n+1 b a = 0 0 a n, m = map(int, input().split()) map(int, input().split()) n
n, m = map(int, input().split())
a = 0; b = n+1
for _ in range(m):
    l, r = map(int, input().split())
    a = max(a, l)
    b = min(b, r)
print(max(0, b-a+1))