import sys if sys.platform =='ios': import clipboard a=clipboard.get() a = a.split('\n') text = '\n'.join(a) with open('input_file.txt','w') as f: f.write(text) sys.stdin = open('input_file.txt') n,m = map(int,input().split()) L = [0]*(n+1) for i in range(m): a,b = map(int,input().split()) a = n-a b = n-b L[a] += 1 L[b+1] -= 1 c = 0 for i in L[:n]: c += i print(c)