N,M = map(int,input().split())
right = N
left = 1
for _ in range(M):
  a,b = map(int,input().split())
  right = min(right,b) 
  left = max(left,a)

ans = right-left+1
print(max(0,ans)) N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M right = N right N left = 1 left 1 for _ in range(M):
  a,b = map(int,input().split())
  right = min(right,b) 
  left = max(left,a) _ range(M) range M a,b = map(int,input().split()) a map(int,input().split()) map int input().split() ().split () input split b right = min(right,b) right min(right,b) min right b left = max(left,a) left max(left,a) max left a ans = right-left+1 ans right-left+1 right-left right left 1 print(max(0,ans)) print max(0,ans) max 0 ans b = map(int,input().split()) map(int,input().split()) b M = map(int,input().split()) map(int,input().split()) M left = max(left,a) max(left,a) left right = min(right,b) min(right,b) right right = N N right N,M = map(int,input().split()) map(int,input().split()) N a,b = map(int,input().split()) map(int,input().split()) a left = 1 1 left ans = right-left+1 right-left+1 ans
N,M = map(int,input().split())
right = N
left = 1
for _ in range(M):
  a,b = map(int,input().split())
  right = min(right,b) 
  left = max(left,a)

ans = right-left+1
print(max(0,ans))