# imos法
n, m = map(int, input().split())
l = []
r = []
imos = [0]*(n+1)
for i in range(m):
    L, R = map(int, input().split())
    l.append(L)
    r.append(R)

for i in range(m):
    imos[l[i]-1] += 1
    imos[r[i]] -= 1

cum_sum = [imos[0]]
for i in range(1, len(imos)):
    cum_sum.append(cum_sum[i - 1] + imos[i])

ans = 0
for count in cum_sum:
    if count == m: ans += 1
print(ans) n, m = map(int, input().split()) n map(int, input().split()) map int input().split() ().split () input split m l = [] l [] r = [] r [] imos = [0]*(n+1) imos [0]*(n+1) [0] 0 n+1 n 1 for i in range(m):
    L, R = map(int, input().split())
    l.append(L)
    r.append(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 l.append(L) l.append l append L r.append(R) r.append r append R for i in range(m):
    imos[l[i]-1] += 1
    imos[r[i]] -= 1 i range(m) range m imos[l[i]-1] += 1 imos[l[i]-1] imos l[i]-1 l[i] l i 1 1 imos[r[i]] -= 1 imos[r[i]] imos r[i] r i 1 cum_sum = [imos[0]] cum_sum [imos[0]] imos[0] imos 0 for i in range(1, len(imos)):
    cum_sum.append(cum_sum[i - 1] + imos[i]) i range(1, len(imos)) range 1 len(imos) len imos cum_sum.append(cum_sum[i - 1] + imos[i]) cum_sum.append cum_sum append cum_sum[i - 1] + imos[i] cum_sum[i - 1] cum_sum i - 1 i 1 imos[i] imos i ans = 0 ans 0 for count in cum_sum:
    if count == m: ans += 1 count cum_sum if count == m: ans  count == m count m print(ans) print ans L, R = map(int, input().split()) map(int, input().split()) L m = map(int, input().split()) map(int, input().split()) m cum_sum = [imos[0]] [imos[0]] cum_sum imos = [0]*(n+1) [0]*(n+1) imos n, m = map(int, input().split()) map(int, input().split()) n R = map(int, input().split()) map(int, input().split()) R ans = 0 0 ans l = [] [] l r = [] [] r
# imos法
n, m = map(int, input().split())
l = []
r = []
imos = [0]*(n+1)
for i in range(m):
    L, R = map(int, input().split())
    l.append(L)
    r.append(R)

for i in range(m):
    imos[l[i]-1] += 1
    imos[r[i]] -= 1

cum_sum = [imos[0]]
for i in range(1, len(imos)):
    cum_sum.append(cum_sum[i - 1] + imos[i])

ans = 0
for count in cum_sum:
    if count == m: ans += 1
print(ans)
