N, M = [int(a) for a in input().split()]
L = []
R = []

for _ in range(M):
    l, r = [int(a) for a in input().split()]
    L.append(l)
    R.append(r)

mingate = max(L)
maxgate = min(R)
ans = max(maxgate - mingate + 1, 0)
print(ans) int(a) for a in input().split() for a in input().split() a input().split() ().split () input split for a in input().split() int(a) int a N, M = [int(a) for a in input().split()] N [int(a) for a in input().split()] M L = [] L [] R = [] R [] for _ in range(M):
    l, r = [int(a) for a in input().split()]
    L.append(l)
    R.append(r) _ range(M) range M int(a) for a in input().split() for a in input().split() a input().split() ().split () input split for a in input().split() int(a) int a l, r = [int(a) for a in input().split()] l [int(a) for a in input().split()] r L.append(l) L.append L append l R.append(r) R.append R append r mingate = max(L) mingate max(L) max L maxgate = min(R) maxgate min(R) min R ans = max(maxgate - mingate + 1, 0) ans max(maxgate - mingate + 1, 0) max maxgate - mingate + 1 maxgate - mingate maxgate mingate 1 0 print(ans) print ans maxgate = min(R) min(R) maxgate N, M = [int(a) for a in input().split()] [int(a) for a in input().split()] N L = [] [] L ans = max(maxgate - mingate + 1, 0) max(maxgate - mingate + 1, 0) ans R = [] [] R M = [int(a) for a in input().split()] [int(a) for a in input().split()] M mingate = max(L) max(L) mingate l, r = [int(a) for a in input().split()] [int(a) for a in input().split()] l r = [int(a) for a in input().split()] [int(a) for a in input().split()] r
N, M = [int(a) for a in input().split()]
L = []
R = []

for _ in range(M):
    l, r = [int(a) for a in input().split()]
    L.append(l)
    R.append(r)

mingate = max(L)
maxgate = min(R)
ans = max(maxgate - mingate + 1, 0)
print(ans)