N, M = map(int, input().split())
dp = [0] * (N+1)
for i in range(M):
    l, r = map(int, input().split())
    dp[l-1] += 1
    dp[r] -= 1

for i in range(N):
    dp[i+1] += dp[i]

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

for i in range(N):
    dp[i+1] += dp[i]

ans = 0
for i in range(N):
    if dp[i] == M:
        ans += 1

print(ans)