n, b = map(int, input().split()) points = [] for _ in range(n): x, y, p = map(int, input().split()) points.append((x, y, p)) # Sort the points by their Y-coordinate points.sort(key=lambda p: p[1]) max_count = 0 current_sum = 0 left = 0 for right in range(n): current_sum += points[right][2] # If current_sum exceeds B, move left pointer to reduce the window while current_sum > b: current_sum -= points[left][2] left += 1 # Update the maximum count of points in the window window_size = right - left + 1 if window_size > max_count: max_count = window_size print(max_count)