n, m = map(int, input().split())
ans = [i for i in range(1, n + 1)]

l_max = 0
r_min = n

for _ in range(m):
    x, y = map(int, input().split())
    l_max = max(l_max, x)
    r_min = min(r_min, y)

print(len([i for i in range(l_max, r_min + 1)])) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m i for i in range(1, n + 1) for i in range(1, n + 1) i range(1, n + 1) range 1 n + 1 n 1 for i in range(1, n + 1) i ans = [i for i in range(1, n + 1)] ans [i for i in range(1, n + 1)] l_max = 0 l_max 0 r_min = n r_min n for _ in range(m):
    x, y = map(int, input().split())
    l_max = max(l_max, x)
    r_min = min(r_min, y) _ range(m) range m x, y = map(int, input().split()) x map(int, input().split()) map int input().split() ().split () input split y l_max = max(l_max, x) l_max max(l_max, x) max l_max x r_min = min(r_min, y) r_min min(r_min, y) min r_min y i for i in range(l_max, r_min + 1) for i in range(l_max, r_min + 1) i range(l_max, r_min + 1) range l_max r_min + 1 r_min 1 for i in range(l_max, r_min + 1) i print(len([i for i in range(l_max, r_min + 1)])) print len([i for i in range(l_max, r_min + 1)]) len [i for i in range(l_max, r_min + 1)] y = map(int, input().split()) map(int, input().split()) y n, m = map(int, input().split()) map(int, input().split()) n r_min = n n r_min r_min = min(r_min, y) min(r_min, y) r_min l_max = max(l_max, x) max(l_max, x) l_max m = map(int, input().split()) map(int, input().split()) m x, y = map(int, input().split()) map(int, input().split()) x ans = [i for i in range(1, n + 1)] [i for i in range(1, n + 1)] ans l_max = 0 0 l_max
n, m = map(int, input().split())
ans = [i for i in range(1, n + 1)]

l_max = 0
r_min = n

for _ in range(m):
    x, y = map(int, input().split())
    l_max = max(l_max, x)
    r_min = min(r_min, y)

print(len([i for i in range(l_max, r_min + 1)]))
