N, M = map(int, input().split())
LL = 0
RR = N
for i in range(M):
    L, R = map(int, input().split())
    if LL < L:
        LL = L
    if RR > R:
        RR = R
print(max(0, RR - LL + 1)) N, M = map(int, input().split()) N map(int, input().split()) map int input().split() ().split () input split M LL = 0 LL 0 RR = N RR N for i in range(M):
    L, R = map(int, input().split())
    if LL < L:
        LL = L
    if RR > R:
        RR = 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 LL < L:
        LL = L
     LL < L LL L LL = L LL L if RR > R:
        RR = R RR > R RR R RR = R RR R print(max(0, RR - LL + 1)) print max(0, RR - LL + 1) max 0 RR - LL + 1 RR - LL RR LL 1 R = map(int, input().split()) map(int, input().split()) R RR = R R RR N, M = map(int, input().split()) map(int, input().split()) N L, R = map(int, input().split()) map(int, input().split()) L LL = L L LL RR = N N RR M = map(int, input().split()) map(int, input().split()) M LL = 0 0 LL
N, M = map(int, input().split())
LL = 0
RR = N
for i in range(M):
    L, R = map(int, input().split())
    if LL < L:
        LL = L
    if RR > R:
        RR = R
print(max(0, RR - LL + 1))
