N, W = map(int, input().split()) Q =[] ans =-1 for item in range(N): v, w = map(int, input().split()) Q.append([w, v]) # TODO: write code... Q.sort(reverse=True) for w, v in Q: if w > W: continue ans = max(ans, v) print(ans)