#yuki994 n,k=map(int,raw_input().split()) l=[] for i in range(n): a,b=map(int,raw_input().split()) l.append((a,b)) if k>n: print -1 else: print k-1