N,M = map(int,input().split())
minimum = 1
maximum = N 
for i in range(M):
    L,R = map(int,input().split())
    minimum = max(minimum,L)
    maximum = min(maximum,R)
    if minimum > maximum:
        print(0)
        exit(0)

print(maximum - minimum + 1) N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M minimum = 1 minimum 1 maximum = N maximum N for i in range(M):
    L,R = map(int,input().split())
    minimum = max(minimum,L)
    maximum = min(maximum,R)
    if minimum > maximum:
        print(0)
        exit(0) i range(M) range M L,R = map(int,input().split()) L map(int,input().split()) map int input().split() ().split () input split R minimum = max(minimum,L) minimum max(minimum,L) max minimum L maximum = min(maximum,R) maximum min(maximum,R) min maximum R if minimum > maximum:
        print(0)
        exit(0) minimum > maximum minimum maximum print(0) print 0 exit(0) exit 0 print(maximum - minimum + 1) print maximum - minimum + 1 maximum - minimum maximum minimum 1 maximum = N N maximum R = map(int,input().split()) map(int,input().split()) R M = map(int,input().split()) map(int,input().split()) M maximum = min(maximum,R) min(maximum,R) maximum minimum = 1 1 minimum N,M = map(int,input().split()) map(int,input().split()) N L,R = map(int,input().split()) map(int,input().split()) L minimum = max(minimum,L) max(minimum,L) minimum
N,M = map(int,input().split())
minimum = 1
maximum = N 
for i in range(M):
    L,R = map(int,input().split())
    minimum = max(minimum,L)
    maximum = min(maximum,R)
    if minimum > maximum:
        print(0)
        exit(0)

print(maximum - minimum + 1)