# coding: utf-8

(N, M) = map(int, input().split(" "))

ids = list(range(1, N+1))

L_max = 0
R_min = 10000000000000000000
for _ in range(M):
    (L, R) = map(int, input().split(" "))
    if L > L_max:
        L_max = L
    if R < R_min:
        R_min = R

ids = [i for i in ids if L_max <= i <= R_min]
print(len(ids)) (N, M) = map(int, input().split(" ")) (N, M) N M map(int, input().split(" ")) map int input().split(" ") ().split () input split " " ids = list(range(1, N+1)) ids list(range(1, N+1)) list range(1, N+1) range 1 N+1 N 1 L_max = 0 L_max 0 R_min = 10000000000000000000 R_min 10000000000000000000 for _ in range(M):
    (L, R) = map(int, input().split(" "))
    if L > L_max:
        L_max = L
    if R < R_min:
        R_min = R _ range(M) range M (L, R) = map(int, input().split(" ")) (L, R) L R map(int, input().split(" ")) map int input().split(" ") ().split () input split " " if L > L_max:
        L_max = L
     L > L_max L L_max L_max = L L_max L if R < R_min:
        R_min = R R < R_min R R_min R_min = R R_min R i for i in ids if L_max <= i <= R_min for i in ids if L_max <= i <= R_min i ids L_max <= i <= R_min L_max <= i L_max i R_min if L_max <= i <= R_min i ids = [i for i in ids if L_max <= i <= R_min] ids [i for i in ids if L_max <= i <= R_min] print(len(ids)) print len(ids) len ids R_min = 10000000000000000000 10000000000000000000 R_min L_max = L L L_max ids = [i for i in ids if L_max <= i <= R_min] [i for i in ids if L_max <= i <= R_min] ids L_max = 0 0 L_max R_min = R R R_min ids = list(range(1, N+1)) list(range(1, N+1)) ids
# coding: utf-8

(N, M) = map(int, input().split(" "))

ids = list(range(1, N+1))

L_max = 0
R_min = 10000000000000000000
for _ in range(M):
    (L, R) = map(int, input().split(" "))
    if L > L_max:
        L_max = L
    if R < R_min:
        R_min = R

ids = [i for i in ids if L_max <= i <= R_min]
print(len(ids))
