n, m = map(int, input().split())
ok = [0] * (n + 2)
ans = 0
for _ in range(m):
    l, r = map(int, input().split())
    ok[l] += 1
    ok[r + 1] -= 1
for i in range(1, n + 2):
    ok[i] += ok[i - 1]
    if ok[i] == m:
        ans += 1
print(ans) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m ok = [0] * (n + 2) ok [0] * (n + 2) [0] 0 n + 2 n 2 ans = 0 ans 0 for _ in range(m):
    l, r = map(int, input().split())
    ok[l] += 1
    ok[r + 1] -= 1 _ range(m) range m l, r = map(int, input().split()) l map(int, input().split()) map int input().split() ().split () input split r ok[l] += 1 ok[l] ok l 1 ok[r + 1] -= 1 ok[r + 1] ok r + 1 r 1 1 for i in range(1, n + 2):
    ok[i] += ok[i - 1]
    if ok[i] == m:
        ans += 1 i range(1, n + 2) range 1 n + 2 n 2 ok[i] += ok[i - 1] ok[i] ok i ok[i - 1] ok i - 1 i 1 if ok[i] == m:
        ans += 1 ok[i] == m ok[i] ok i m ans += 1 ans 1 print(ans) print ans ans += 1 1 ans r = map(int, input().split()) map(int, input().split()) r 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 ans = 0 0 ans ok = [0] * (n + 2) [0] * (n + 2) ok
n, m = map(int, input().split())
ok = [0] * (n + 2)
ans = 0
for _ in range(m):
    l, r = map(int, input().split())
    ok[l] += 1
    ok[r + 1] -= 1
for i in range(1, n + 2):
    ok[i] += ok[i - 1]
    if ok[i] == m:
        ans += 1
print(ans)