# -*- coding: utf-8 -*-
import numpy as np
n, m = map(int, input().split())


cards = np.zeros(n+1, dtype=int)

for _ in range(m):
    l,r = map(int, input().split())
    cards[l-1] += 1
    cards[r] -= 1

cum = cards.cumsum()

print(len(cum[cum==m])) import numpy as np numpy n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m cards = np.zeros(n+1, dtype=int) cards np.zeros(n+1, dtype=int) np.zeros np zeros n+1 n 1 dtype=int dtype int for _ in range(m):
    l,r = map(int, input().split())
    cards[l-1] += 1
    cards[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 cards[l-1] += 1 cards[l-1] cards l-1 l 1 1 cards[r] -= 1 cards[r] cards r 1 cum = cards.cumsum() cum cards.cumsum() cards.cumsum cards cumsum print(len(cum[cum==m])) print len(cum[cum==m]) len cum[cum==m] cum cum==m cum m m = map(int, input().split()) map(int, input().split()) m l,r = map(int, input().split()) map(int, input().split()) l cum = cards.cumsum() cards.cumsum() cum r = map(int, input().split()) map(int, input().split()) r n, m = map(int, input().split()) map(int, input().split()) n cards = np.zeros(n+1, dtype=int) np.zeros(n+1, dtype=int) cards
# -*- coding: utf-8 -*-
import numpy as np
n, m = map(int, input().split())


cards = np.zeros(n+1, dtype=int)

for _ in range(m):
    l,r = map(int, input().split())
    cards[l-1] += 1
    cards[r] -= 1

cum = cards.cumsum()

print(len(cum[cum==m]))
