""" N,ww = map(int, input().split()) dp = [ [-float("inf")] * (10**6+1) for _ in range(N+1) ] for i in range(ww+1): dp[0][i] = 0 V = list() W = list() for _ in range(N): v,w = map(int, input().split()) V.append(v) W.append(w) for i in range(N): for j in range(ww+1): if W[i]<=j: dp[i+1][j] = max(dp[i][j-W[i]]+V[i],dp[i][j]) else: dp[i+1][j] = dp[i][j] print(dp[N][ww] if dp[N][ww] > 0 else -1) """ ans = -1 N,W = map(int, input().split()) for _ in range(N): v,w = map(int, input().split()) if w <= W: ans = max(ans, v) print(ans)