while True:
    try:
        arr=[]
        L, M = map(int, input().split())
        for i in range(L+1):
            arr.append(1)
        for i in range(M):
            a, b = map(int, input().split())
            for j in range(a, b+1):
                arr[j] = 0
        a = arr.count(1)
        print(a)
    except:
        break