N, M = map(int, input().split())
L = 1
R = N
for i in range(M):
  l, r = map(int, input().split())
  if L < l:
    L = l
  if R > r:
    R = r
print(max(1+R-L, 0))  N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M L = 1 L 1 R = N R N for i in range(M):
  l, r = map(int, input().split())
  if L < l:
    L = l
  if R > r:
    R = r i range(M) range M l, r = map(int, input().split()) l map(int, input().split()) map int input().split() ().split () input split r if L < l:
    L = l
   L < l L l L = l L l if R > r:
    R = r R > r R r R = r R r print(max(1+R-L, 0)) print max(1+R-L, 0) max 1+R-L 1+R 1 R L 0 N, M = map(int, input().split()) map(int, input().split()) N L = l l L M = map(int, input().split()) map(int, input().split()) M L = 1 1 L l, r = map(int, input().split()) map(int, input().split()) l r = map(int, input().split()) map(int, input().split()) r R = N N R R = r r R
N, M = map(int, input().split())
L = 1
R = N
for i in range(M):
  l, r = map(int, input().split())
  if L < l:
    L = l
  if R > r:
    R = r
print(max(1+R-L, 0)) 