from collections import defaultdict from operator import itemgetter import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) inf = 10**18 N, B = map(int, input().split()) P = list(tuple(map(int, input().split())) for _ in range(N)) P.sort(key=itemgetter(1)) X, _, _ = zip(*P) X = sorted(set(X)) ans = 0 for i in range(len(X)): for j in range(i, len(X)): l = 0 r = 0 cnt = 0 score = 0 while r < N: yr = P[r][1] while r < N and P[r][1] == yr: if X[i] <= P[r][0] <= X[j]: cnt += 1 score += P[r][2] r += 1 while score > B: yl = P[l][1] while l < N and P[l][1] == yl: if X[i] <= P[l][0] <= X[j]: cnt -= 1 score -= P[l][2] l += 1 ans = max(ans, cnt) print(ans)