import sys def d(i, j): return abs(X[i] - X[j]) + abs(Y[i] - Y[j]) N, A, B = map(int, sys.stdin.readline().split()) X, Y, K = [], [], [] for _ in range(N): x, y, k = map(int, sys.stdin.readline().split()) X.append(x) Y.append(y) K.append(k) dp = [[[0] * N for _ in range(N)] for _ in range(1 << N)] for i in range(N): for j in range(N): if i != j: dp[(1 << i) | (1 << j)][i][j] = int(d(i, j) >= A or abs(K[i] - K[j]) >= B) for bit in range(1 << N): for i in range(N): for j in range(N): if dp[bit][i][j] and bit == (bit | (1 << i)) and bit == (bit | (1 << j)): for k in range(N): if not bit & (1 << k): if d(k, i) + d(k, j) >= A or abs(K[i] - K[k]) >= B: dp[bit | (1 << k)][k][i] = 1 ans = 1 for i in range(1 << N): for j in range(N): for k in range(N): if dp[i][j][k]: ans = max(ans, bin(i).count("1")) print(ans)