import sys input = sys.stdin.readline N, B = map(int, input().split()) X, Y, P = [0] * N, [0] * N, [0] * N XS = set() for i in range(N): X[i], Y[i], P[i] = map(int, input().split()) XS.add(X[i]) from collections import * def solve(L): inf = 10 ** 18 L.sort() K = len(L) L.append((inf, inf)) Q = deque() now = -1 val = 0 temp = 0 for i in range(K): Q.append(L[i]) val += L[i][1] if L[i][0] == L[i + 1][0]: continue while Q: if val > B or Q[0][0] == now: now = Q[0][0] val -= Q[0][1] Q.popleft() else: break temp = max(temp, len(Q)) return temp XL = sorted(list(XS)) M = len(XL) ans = 0 for i in range(M): for j in range(i, M): left = XL[i] right = XL[j] D = [] for k in range(N): if left <= X[k] <= right: D.append((Y[k], P[k])) ans = max(ans, solve(D)) print(ans)