n,m = map(int,input().split()) t = (3 * m) // 2 d = {} score=[] for _ in range(n): k,s = map(int,input().split()) d[k] = s score.append(s) score.sort(reverse = True) d_sorted = dict(sorted(d.items(), key=lambda x: (-x[1], x[0]))) line = score[t-1] cnt = 0 for i in score: if i>=line: cnt+=1 print(...