import java.awt.Point; import java.awt.Rectangle; import java.awt.geom.Rectangle2D; import java.io.BufferedInputStream; import java.io.IOException; import java.math.BigDecimal; import java.math.BigInteger; import java.util.*; import java.util.Map.Entry; import java.util.concurrent.ConcurrentSkipListSet; public class Main { public static final int C = 1000000007; static final int CY = 1000000000; //static boolean MAP[][]; static int N; static int B; static int[][] POS; static String S; static int K; static int X[][]; //static String S[]; static int HA[]; static long DP[]; static int ST[][]; static ConcurrentSkipListSet TS; static ArrayList AL; public static void main(String[] args) { StringBuilder sb = new StringBuilder(); BufferedInputStream bs = new BufferedInputStream(System.in); Scanner sc = new Scanner(bs); N = sc.nextInt(); B = sc.nextInt(); HashSet X = new HashSet(); HashSet Y = new HashSet(); POS = new int[N][3]; for (int i=0; i < N; i++) { POS[i][0] = sc.nextInt()*2; POS[i][1] = sc.nextInt()*2; POS[i][2] = sc.nextInt(); X.add(POS[i][0]); Y.add(POS[i][1]); } long ans = 1; for (int x1 :X) { LOOP:for (int x2: X) { for(int y1: Y) { for (int y2:Y) { int x = Math.min(x1, x2) - 1; int y = Math.min(y1, y2) - 1; Rectangle rect = new Rectangle(x, y,Math.abs(x1 - x2) + 2, Math.abs(y1 - y2)+ 2); int num = 0; int b = 0; for (int t=0; t < N; t++) { if (rect.contains(new Point(POS[t][0], POS[t][1]))) { num++; b += POS[t][2]; if (b > B) { continue LOOP; } } } ans = Math.max(ans, num); } } } } System.out.println(ans); } }