def popcount(n): cnt = 0 while n: cnt += n & 1 n //= 2 return cnt N, A, B = map(int, input().split()) X, Y, K = [0] * N, [0] * N, [0] * N for i in range(N): X[i], Y[i], K[i] = map(int, input().split()) N2 = 1 << N dp = [0] * N*N*N2 def f(s, a, b): return s * N ** 2 + a * N + b def dist(a, b): return abs(X[a] - X[b]) + abs(Y[a] - Y[b]) def check2(a, b): if A <= dist(a, b): return True if B <= abs(K[a] - K[b]): return True return False def check3(a, b, c): if B <= abs(K[a] - K[b]): return True if A <= dist(a, b) + dist(a, c): return True return False for s in range(1, N2): p = popcount(s) for i in range(N): if (s >> i) & 1: continue if p == 1: for j in range(N): if (s >> j) & 1 == 0: continue if check2(i, j): dp[f(s|(1 << i),i,j)] = 1 else: for j in range(N): if (s >> j) & 1 == 0: continue for k in range(N): if k == i or k == j or (s >> k) & 1 == 0: continue if check3(i, j, k): dp[f(s|(1 << i),i,j)] |= dp[f(s,j,k)] ans = 1 for s in range(1, N2): for i in range(N): for j in range(N): if dp[f(s,i,j)]: ans = max(ans, popcount(s)) print(ans)