import java.util.Scanner; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int a = sc.nextInt(); int b = sc.nextInt(); int[] x = new int[n]; int[] y = new int[n]; int[] k = new int[n]; for (int i = 0; i < n; i++) { x[i] = sc.nextInt(); y[i] = sc.nextInt(); k[i] = sc.nextInt(); } sc.close(); int[][] d = new int[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { d[i][j] = Math.abs(x[i] - x[j]) + Math.abs(y[i] - y[j]); d[j][i] = d[i][j]; } } int n2 = 1 << n; boolean[][][] dp = new boolean[n2][n][n]; for (int j = 0; j < n; j++) { for (int j2 = 0; j2 < n; j2++) { if (j == j2) { continue; } if (a <= d[j][j2] || b <= Math.abs(k[j] - k[j2])) { dp[(1 << j) | 1 << j2][j][j2] = true; } } } for (int i = 1; i < n2; i++) { for (int j = 0; j < n; j++) { for (int j2 = 0; j2 < n; j2++) { if (dp[i][j][j2]) { for (int j3 = 0; j3 < n; j3++) { if ((i >> j3 & 1) == 0) { int ni = i | (1 << j3); if (b <= Math.abs(k[j3] - k[j2])) { dp[ni][j2][j3] = true; } if (a <= d[j3][j2] + d[j3][j]) { dp[ni][j2][j3] = true; } } } } } } } int ans = 1; for (int i = 0; i < n2; i++) { for (int j = 0; j < n; j++) { for (int j2 = 0; j2 < n; j2++) { if (dp[i][j][j2]) { ans = Math.max(ans, Integer.bitCount(i)); } } } } System.out.println(ans); } }