N, A, B = map(int, input().split()) balls = [tuple(map(int, input().split())) for _ in range(N)] def dist(i, j): return abs(balls[i][0] - balls[j][0]) + abs(balls[i][1] - balls[j][1]) dp = [0] * (1 << N) for S in range(1, 1 << N): for i in range(N): if (S >> i) & 1: T = S ^ (1 << i) if T == 0: dp[S] = 1 else: for j in range(N): if (T >> j) & 1: if A <= dist(i, j): dp[S] = max(dp[S], dp[T] + 1) if abs(balls[i][2] - balls[j][2]) >= B: dp[S] = max(dp[S], dp[T] + 1) U = T ^ (1 << j) if U != 0: for k in range(N): if (U >> k) & 1: if A <= dist(i, j) + dist(i, k): dp[S] = max(dp[S], dp[T] + 1) print(dp[(1 << N) - 1])