N, W = map(int, input().rstrip().split(" ")) # nは入力回数 vw_list = [list(map(int, input().split())) for _ in range(N)] max_v = 0 max_v_dict = {} w_list = [] for i in sorted(vw_list, key=lambda x: x[1]): if i[0] > max_v: max_v = i[0] max_v_dict[i[1]] = max_v w_list.append(i[1]) if W < w_list[0]: print(-1) exit() while True: c_idx = int(len(w_list) / 2) if W < w_list[c_idx]: w_list = w_list[:c_idx] if W > w_list[-1]: print(max_v_dict[w_list[-1]]) exit() else: w_list = w_list[c_idx:] if len(w_list) == 1 or W < w_list[1]: print(max_v_dict[w_list[0]]) exit()