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(); 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(); } long ans = 1; for (int i=0; i < N; i++) { LOOP:for (int n=i+1; n < N; n++) { int x = Math.min(POS[i][0], POS[n][0]) - 1; int y = Math.min(POS[i][1], POS[n][1]) - 1; Rectangle rect = new Rectangle(x, y,Math.abs(POS[i][0] - POS[n][0]) +2, Math.abs(POS[i][1] - POS[n][1])+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) { //System.out.println(num); continue LOOP; } } } ans = Math.max(ans, num); } } System.out.println(ans); } }