n, m = map(int, input().split())
cards = [0] * n
for i in range(m):
    l, r = map(lambda x: int(x)-1, input().split())
    cards[l] += 1
    if r+1 < n:
        cards[r+1] -= 1

from itertools import accumulate
ac = list(accumulate(cards))

ans = 0
for a in ac:
    if a == m:
        ans += 1
print(ans) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m cards = [0] * n cards [0] * n [0] 0 n for i in range(m):
    l, r = map(lambda x: int(x)-1, input().split())
    cards[l] += 1
    if r+1 < n:
        cards[r+1] -= 1 i range(m) range m l, r = map(lambda x: int(x)-1, input().split()) l map(lambda x: int(x)-1, input().split()) map lambda x: int(x)-1 int(x)-1 int(x) int x 1 x input().split() ().split () input split r cards[l] += 1 cards[l] cards l 1 if r+1 < n:
        cards[r+1] -= 1 r+1 < n r+1 r 1 n cards[r+1] -= 1 cards[r+1] cards r+1 r 1 1 from itertools import accumulate ac = list(accumulate(cards)) ac list(accumulate(cards)) list accumulate(cards) accumulate cards ans = 0 ans 0 for a in ac:
    if a == m:
        ans += 1 a ac if a == m:
        ans += 1 a == m a m ans += 1 ans 1 print(ans) print ans ans = 0 0 ans m = map(int, input().split()) map(int, input().split()) m r = map(lambda x: int(x)-1, input().split()) map(lambda x: int(x)-1, input().split()) r cards = [0] * n [0] * n cards l, r = map(lambda x: int(x)-1, input().split()) map(lambda x: int(x)-1, input().split()) l n, m = map(int, input().split()) map(int, input().split()) n ac = list(accumulate(cards)) list(accumulate(cards)) ac ans += 1 1 ans
n, m = map(int, input().split())
cards = [0] * n
for i in range(m):
    l, r = map(lambda x: int(x)-1, input().split())
    cards[l] += 1
    if r+1 < n:
        cards[r+1] -= 1

from itertools import accumulate
ac = list(accumulate(cards))

ans = 0
for a in ac:
    if a == m:
        ans += 1
print(ans)
