import numpy as np
n, m = map(int, input().split())
ans = [0]*n

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

c = list(np.cumsum(ans))
print(c.count(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 ans = [0]*n ans [0]*n [0] 0 n for _ in range(m):
    l, r = map(int, input().split())
    ans[l-1] += 1
    if r < n:
        ans[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 ans[l-1] += 1 ans[l-1] ans l-1 l 1 1 if r < n:
        ans[r] -= 1 r < n r n ans[r] -= 1 ans[r] ans r 1 c = list(np.cumsum(ans)) c list(np.cumsum(ans)) list np.cumsum(ans) np.cumsum np cumsum ans print(c.count(m)) print c.count(m) c.count c count m c = list(np.cumsum(ans)) list(np.cumsum(ans)) c m = map(int, input().split()) map(int, input().split()) m ans = [0]*n [0]*n ans l, r = map(int, input().split()) map(int, input().split()) l n, m = map(int, input().split()) map(int, input().split()) n r = map(int, input().split()) map(int, input().split()) r
import numpy as np
n, m = map(int, input().split())
ans = [0]*n

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

c = list(np.cumsum(ans))
print(c.count(m))