#!/usr/bin/ python3.8 # %% import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import itertools N, B = map(int, readline().split()) m = map(int, read().split()) X, Y, P = zip(*zip(m, m, m)) def compress(A): x_to_i = {x: i for i, x in enumerate(sorted(set(A)))} return tuple(x_to_i[x] for x in A) X = compress(X) Y = compress(Y) H = max(X) W = max(Y) best_N = 0 for i, j in itertools.combinations(range(W + 2), 2): Ns = [0] * (H + 2) Ps = [0] * (H + 2) INF = B + 10 Ps[-1] = INF for x, y, p in zip(X, Y, P): if i <= y < j: Ns[x] += 1 Ps[x] += p R = 0 S = 0 N = 0 for L in range(H + 1): while R < L or S + Ps[R] <= B: N += Ns[R] S += Ps[R] R += 1 if best_N < N: best_N = N S -= Ps[L] N -= Ns[L] print(best_N)