import math x = [0] * 15 y = [0] * 15 def d(a, b): return abs(x[a] - x[b]) + abs(y[a] - y[b]) n, a, b = map(int, input().split()) c = n + 1 k = [0] * 15 for i in range(1, n + 1): x[i], y[i], k[i] = map(int, input().split()) dp = [[[0] * (n + 1) for _ in range(n + 1)] for _ in range(1 << c)] for i in range(1, n + 1): dp[(1 << i) + 1][0][i] = 1 for i in range(1 << c): for j in range(n + 1): for l in range(1, n + 1): if j == l: continue if ((1 << j) & i) == 0 or ((1 << l) & i) == 0: continue for m in range(n + 1): if m != 0 and j == 0: continue if m == 0: if d(l, j) >= a or abs(k[l] - k[j]) >= b: if m == l or j == m: continue dp[i ^ (1 << l)][m][j] = max(dp[i ^ (1 << l)][m][j], dp[i ^ (1 << l)][m][j] + 1) else: if d(l, j) + d(l, m) >= a or abs(k[l] - k[j]) >= b: if m == l or j == m: continue dp[i ^ (1 << l)][m][j] = max(dp[i ^ (1 << l)][m][j], dp[i ^ (1 << l)][m][j] + 1) ans = 0 for i in range(1 << c): for j in range(n + 1): for l in range(n + 1): ans = max(ans, dp[i][j][l]) print(ans)