N,M = map(int, input().split())
Key = [0 for i in range(N+1)]
for _ in range(M):
    L,R = map(int,input().split())
    L -= 1
    R -= 1
    Key[L] += 1
    Key[R+1] -= 1
count = 0
sum = 0
for i in range(len(Key)):
    sum += Key[i]
    if sum == M:
        count += 1
print(count) 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 Key = [0 for i in range(N+1)] Key [0 for i in range(N+1)] for _ in range(M):
    L,R = map(int,input().split())
    L -= 1
    R -= 1
    Key[L] += 1
    Key[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 L -= 1 L 1 R -= 1 R 1 Key[L] += 1 Key[L] Key L 1 Key[R+1] -= 1 Key[R+1] Key R+1 R 1 1 count = 0 count 0 sum = 0 sum 0 for i in range(len(Key)):
    sum += Key[i]
    if sum == M:
        count += 1 i range(len(Key)) range len(Key) len Key sum += Key[i] sum Key[i] Key i if sum == M:
        count += 1 sum == M sum M count += 1 count 1 print(count) print count Key = [0 for i in range(N+1)] [0 for i in range(N+1)] Key N,M = map(int, input().split()) map(int, input().split()) N L -= 1 1 L R -= 1 1 R count = 0 0 count M = map(int, input().split()) map(int, input().split()) M L,R = map(int,input().split()) map(int,input().split()) L sum = 0 0 sum sum += Key[i] Key[i] sum R = map(int,input().split()) map(int,input().split()) R count += 1 1 count
N,M = map(int, input().split())
Key = [0 for i in range(N+1)]
for _ in range(M):
    L,R = map(int,input().split())
    L -= 1
    R -= 1
    Key[L] += 1
    Key[R+1] -= 1
count = 0
sum = 0
for i in range(len(Key)):
    sum += Key[i]
    if sum == M:
        count += 1
print(count)