N, M = map(int, input().split())
LR = [list(map(int, input().split())) for i in range(M)]
Lmax = max([lr[0] for lr in LR])
Rmin = min([lr[1] for lr in LR])
if Rmin >= Lmax:
    print(Rmin - Lmax + 1)
else:
    print(0) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M list(map(int, input().split())) for i in range(M) for i in range(M) i range(M) range M for i in range(M) list(map(int, input().split())) list map(int, input().split()) map int input().split() ().split () input split LR = [list(map(int, input().split())) for i in range(M)] LR [list(map(int, input().split())) for i in range(M)] lr[0] for lr in LR for lr in LR lr LR for lr in LR lr[0] lr 0 Lmax = max([lr[0] for lr in LR]) Lmax max([lr[0] for lr in LR]) max [lr[0] for lr in LR] lr[1] for lr in LR for lr in LR lr LR for lr in LR lr[1] lr 1 Rmin = min([lr[1] for lr in LR]) Rmin min([lr[1] for lr in LR]) min [lr[1] for lr in LR] if Rmin >= Lmax:
    print(Rmin - Lmax + 1)
else:
    print(0) Rmin >= Lmax Rmin Lmax print(Rmin - Lmax + 1) print Rmin - Lmax + 1 Rmin - Lmax Rmin Lmax 1 print(0) print 0 LR = [list(map(int, input().split())) for i in range(M)] [list(map(int, input().split())) for i in range(M)] LR Rmin = min([lr[1] for lr in LR]) min([lr[1] for lr in LR]) Rmin N, M = map(int, input().split()) map(int, input().split()) N Lmax = max([lr[0] for lr in LR]) max([lr[0] for lr in LR]) Lmax M = map(int, input().split()) map(int, input().split()) M
N, M = map(int, input().split())
LR = [list(map(int, input().split())) for i in range(M)]
Lmax = max([lr[0] for lr in LR])
Rmin = min([lr[1] for lr in LR])
if Rmin >= Lmax:
    print(Rmin - Lmax + 1)
else:
    print(0)
