N, M = map(int, input().split())
c = [0 for i in range(N+1)]
for x in range(M):
    L, R = map(int, input().split())
    c[L-1] += 1
    c[R] -= 1
r = 0
t = 0
for x in c[:-1]:
    t += x
    if t == M:
        r += 1
print(r) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M 0 for i in range(N+1) for i in range(N+1) i range(N+1) range N+1 N 1 for i in range(N+1) 0 c = [0 for i in range(N+1)] c [0 for i in range(N+1)] for x in range(M):
    L, R = map(int, input().split())
    c[L-1] += 1
    c[R] -= 1 x range(M) range M L, R = map(int, input().split()) L map(int, input().split()) map int input().split() ().split () input split R c[L-1] += 1 c[L-1] c L-1 L 1 1 c[R] -= 1 c[R] c R 1 r = 0 r 0 t = 0 t 0 for x in c[:-1]:
    t += x
    if t == M:
        r += 1 x c[:-1] c :-1 -1 t += x t x if t == M:
        r += 1 t == M t M r += 1 r 1 print(r) print r r = 0 0 r r += 1 1 r c = [0 for i in range(N+1)] [0 for i in range(N+1)] c t = 0 0 t t += x x t N, M = map(int, input().split()) map(int, input().split()) N R = map(int, input().split()) map(int, input().split()) R L, R = map(int, input().split()) map(int, input().split()) L M = map(int, input().split()) map(int, input().split()) M
N, M = map(int, input().split())
c = [0 for i in range(N+1)]
for x in range(M):
    L, R = map(int, input().split())
    c[L-1] += 1
    c[R] -= 1
r = 0
t = 0
for x in c[:-1]:
    t += x
    if t == M:
        r += 1
print(r)
