N, M = map(int,input().split())

L = 0
R = N+1
for _ in range(M):
    l,r = map(int,input().split())
    
    L = max(l,L)
    R = min(r,R)

print(len(range(L,R+1))) N, M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M L = 0 L 0 R = N+1 R N+1 N 1 for _ in range(M):
    l,r = map(int,input().split())
    
    L = max(l,L)
    R = min(r,R) _ range(M) range M l,r = map(int,input().split()) l map(int,input().split()) map int input().split() ().split () input split r L = max(l,L) L max(l,L) max l L R = min(r,R) R min(r,R) min r R print(len(range(L,R+1))) print len(range(L,R+1)) len range(L,R+1) range L R+1 R 1 l,r = map(int,input().split()) map(int,input().split()) l M = map(int,input().split()) map(int,input().split()) M r = map(int,input().split()) map(int,input().split()) r L = max(l,L) max(l,L) L L = 0 0 L N, M = map(int,input().split()) map(int,input().split()) N R = min(r,R) min(r,R) R R = N+1 N+1 R
N, M = map(int,input().split())

L = 0
R = N+1
for _ in range(M):
    l,r = map(int,input().split())
    
    L = max(l,L)
    R = min(r,R)

print(len(range(L,R+1)))