import numpy as np
n, k = map(int,input().split())
gates = [0]*(n+1)
for i in range(k):
  l,r = map(int,input().split())
  gates[l-1] += 1
  gates[r] -= 1
print(np.count_nonzero(np.cumsum(gates) == k)) import numpy as np numpy n, k = map(int,input().split()) n map(int,input().split()) map int input().split() ().split () input split k gates = [0]*(n+1) gates [0]*(n+1) [0] 0 n+1 n 1 for i in range(k):
  l,r = map(int,input().split())
  gates[l-1] += 1
  gates[r] -= 1 i range(k) range k l,r = map(int,input().split()) l map(int,input().split()) map int input().split() ().split () input split r gates[l-1] += 1 gates[l-1] gates l-1 l 1 1 gates[r] -= 1 gates[r] gates r 1 print(np.count_nonzero(np.cumsum(gates) == k)) print np.count_nonzero(np.cumsum(gates) == k) np.count_nonzero np count_nonzero np.cumsum(gates) == k np.cumsum(gates) np.cumsum np cumsum gates k gates = [0]*(n+1) [0]*(n+1) gates n, k = map(int,input().split()) map(int,input().split()) n r = map(int,input().split()) map(int,input().split()) r k = map(int,input().split()) map(int,input().split()) k l,r = map(int,input().split()) map(int,input().split()) l
import numpy as np
n, k = map(int,input().split())
gates = [0]*(n+1)
for i in range(k):
  l,r = map(int,input().split())
  gates[l-1] += 1
  gates[r] -= 1
print(np.count_nonzero(np.cumsum(gates) == k))
