n, m = map(int, input().split())
lr = [list(map(int, input().split())) for i in range(m)]
l = []
r = []
for i in range(m):
  l.append(lr[i][0])
  r.append(lr[i][1])
lm = max(l)
rm = min(r)
ans = 0
for i in range(1, n+1):
  if lm <= i <= rm:
    ans += 1
print(ans) 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)] l = [] l [] r = [] r [] for i in range(m):
  l.append(lr[i][0])
  r.append(lr[i][1]) i range(m) range m l.append(lr[i][0]) l.append l append lr[i][0] [i] lr i 0 r.append(lr[i][1]) r.append r append lr[i][1] [i] lr i 1 lm = max(l) lm max(l) max l rm = min(r) rm min(r) min r ans = 0 ans 0 for i in range(1, n+1):
  if lm <= i <= rm:
    ans += 1 i range(1, n+1) range 1 n+1 n 1 if lm <= i <= rm:
    ans += 1 lm <= i <= rm lm <= i lm i rm ans += 1 ans 1 print(ans) print ans lr = [list(map(int, input().split())) for i in range(m)] [list(map(int, input().split())) for i in range(m)] lr lm = max(l) max(l) lm m = map(int, input().split()) map(int, input().split()) m rm = min(r) min(r) rm ans += 1 1 ans l = [] [] l n, m = map(int, input().split()) map(int, input().split()) n r = [] [] r ans = 0 0 ans
n, m = map(int, input().split())
lr = [list(map(int, input().split())) for i in range(m)]
l = []
r = []
for i in range(m):
  l.append(lr[i][0])
  r.append(lr[i][1])
lm = max(l)
rm = min(r)
ans = 0
for i in range(1, n+1):
  if lm <= i <= rm:
    ans += 1
print(ans)