import sys input = sys.stdin.readline N, M = map(int, input().split()) LR = [tuple(map(int, input().split())) for _ in range(M)] LR.sort(reverse=True) now = 10**18 ans = N for L, R in LR: if R