from itertools import permutations N, A, B = map(int, input().split()) XYK = [] for _ in range(N): x, y, k = map(int, input().split()) XYK.append((x, y, k)) coef = [[[0] * (N + 1) for _ in range(N + 1)] for _ in range(N + 1)] def dist(z1, z2): return abs(z1[0] - z2[0]) + abs(z1[1] - z2[1]) for (i, zi), (j, zj) in permutations(enumerate(XYK), 2): if A <= dist(zi, zj): coef[N][i][j] = 1 if B <= abs(zi[2] - zj[2]): for k in range(N + 1): coef[N][i][j] = 1 for (i, zi), (j, zj), (k, zk) in permutations(enumerate(XYK), 3): if A <= dist(zi, zj) + dist(zj, zk): coef[i][j][k] = 1 dp = [[[0] * (N + 1) for _ in range(N + 1)] for _ in range(1 << N)] for i in range(N): dp[1 << i][N][i] = 1 def popcount(n): c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555) c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333) c = (c & 0x0F0F0F0F0F0F0F0F) + ((c >> 4) & 0x0F0F0F0F0F0F0F0F) c = (c & 0x00FF00FF00FF00FF) + ((c >> 8) & 0x00FF00FF00FF00FF) c = (c & 0x0000FFFF0000FFFF) + ((c >> 16) & 0x0000FFFF0000FFFF) c = (c & 0x00000000FFFFFFFF) + ((c >> 32) & 0x00000000FFFFFFFF) return c ans = 0 for group in range(1, 1 << N): flag = False for i in range(N + 1): for j in range(N): if i == j: continue if dp[group][i][j] == 0: continue flag = True for k in range(N): nxt = group | (1 << k) if nxt == group: continue if coef[i][j][k]: dp[nxt][j][k] = 1 if flag: ans = max(ans, popcount(group)) print(ans)