N,M=map(int,input().split())
diff=[0 for _ in range(N+1)]
for _ in range(M):
    L,R=map(int,input().split())
    diff[L-1]+=1
    diff[R]-=1
ans=0
x=0
for i in range(N):
    x+=diff[i]
    if x==M:
        ans+=1
print(ans) N,M=map(int,input().split()) N map(int,input().split()) map int input().split() ().split () input split M 0 for _ in range(N+1) for _ in range(N+1) _ range(N+1) range N+1 N 1 for _ in range(N+1) 0 diff=[0 for _ in range(N+1)] diff [0 for _ in range(N+1)] for _ in range(M):
    L,R=map(int,input().split())
    diff[L-1]+=1
    diff[R]-=1 _ range(M) range M L,R=map(int,input().split()) L map(int,input().split()) map int input().split() ().split () input split R diff[L-1]+=1 diff[L-1] diff L-1 L 1 1 diff[R]-=1 diff[R] diff R 1 ans=0 ans 0 x=0 x 0 for i in range(N):
    x+=diff[i]
    if x==M:
        ans+=1 i range(N) range N x+=diff[i] x diff[i] diff i if x==M:
        ans+=1 x==M x M ans+=1 ans 1 print(ans) print ans M=map(int,input().split()) map(int,input().split()) M ans+=1 1 ans ans=0 0 ans N,M=map(int,input().split()) map(int,input().split()) N x+=diff[i] diff[i] x x=0 0 x R=map(int,input().split()) map(int,input().split()) R L,R=map(int,input().split()) map(int,input().split()) L diff=[0 for _ in range(N+1)] [0 for _ in range(N+1)] diff
N,M=map(int,input().split())
diff=[0 for _ in range(N+1)]
for _ in range(M):
    L,R=map(int,input().split())
    diff[L-1]+=1
    diff[R]-=1
ans=0
x=0
for i in range(N):
    x+=diff[i]
    if x==M:
        ans+=1
print(ans)
