N,M = map(int,input().split())
for i in range(M):
    st,sp = map(int,input().split())
    if i == 0:
        N_List = [st,sp]
    else:
        if st > N_List[0]:
            N_List[0] = st
        if sp < N_List[1]:
            N_List[1] = sp   
print(len(list(range(N_List[0],N_List[1]+1)))) N,M = map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M for i in range(M):
    st,sp = map(int,input().split())
    if i == 0:
        N_List = [st,sp]
    else:
        if st > N_List[0]:
            N_List[0] = st
        if sp < N_List[1]:
            N_List[1] = sp    i range(M) range M st,sp = map(int,input().split()) st map(int,input().split()) map int input().split() ().split () input split sp if i == 0:
        N_List = [st,sp]
    else:
        if st > N_List[0]:
            N_List[0] = st
        if sp < N_List[1]:
            N_List[1] = sp    i == 0 i 0 N_List = [st,sp] N_List [st,sp] st sp if st > N_List[0]:
            N_List[0] = st
         st > N_List[0] st N_List[0] N_List 0 N_List[0] = st N_List[0] N_List 0 st if sp < N_List[1]:
            N_List[1] = sp    sp < N_List[1] sp N_List[1] N_List 1 N_List[1] = sp N_List[1] N_List 1 sp print(len(list(range(N_List[0],N_List[1]+1)))) print len(list(range(N_List[0],N_List[1]+1))) len list(range(N_List[0],N_List[1]+1)) list range(N_List[0],N_List[1]+1) range N_List[0] N_List 0 N_List[1]+1 N_List[1] N_List 1 1 N,M = map(int,input().split()) map(int,input().split()) N sp = map(int,input().split()) map(int,input().split()) sp st,sp = map(int,input().split()) map(int,input().split()) st N_List = [st,sp] [st,sp] N_List M = map(int,input().split()) map(int,input().split()) M
N,M = map(int,input().split())
for i in range(M):
    st,sp = map(int,input().split())
    if i == 0:
        N_List = [st,sp]
    else:
        if st > N_List[0]:
            N_List[0] = st
        if sp < N_List[1]:
            N_List[1] = sp   
print(len(list(range(N_List[0],N_List[1]+1))))