from collections import deque N, K = map(int, input().split()) LR = sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x:x[1]) nex = [N]*N que = deque() for i, (L, R) in enumerate(LR): while que and que[0][0] <= L: n, idx = que.popleft() nex[idx] = i que.append((R, i)) nex = [nex[:]] for i in range(29): A = [] for j in range(N): if nex[i][j] < N: A.append(nex[i][nex[i][j]]) else: A.append(N) nex.append(A) ans = 10**18 K -= 1 for i in range(N): goal = i for j in range(30): if 1<