#include using namespace std; int main () { int N, A, B; cin >> N >> A >> B; int X[20], Y[20], K[20]; for (int i = 0; i < N; i ++) cin >> X[i] >> Y[i] >> K[i]; bool dp[(1 << 14)][14][14]; std::vector P; for (auto& a : dp) { for (auto& b : a) { for (auto& c : b) { c = false; } } } auto dst = [&](int a, int b) -> int{ return abs(X[a] - X[b]) + abs(Y[a] - Y[b]); }; int ans = 1; for (int i = 0; i < (1 << N); i ++) { P.clear(); for (int j = 0; j < N; j ++) { if ((i >> j) & 1) { P.push_back(j); } } if (P.size() < 2) { } else if (P.size() == 2) { int a = P[0], b = P[1]; dp[i][a][b] = dp[i][b][a] = (dst(a, b) >= A && abs(K[a] - K[b]) >= B); if (dp[i][a][b]) { ans = max(ans, 2); } } else { for (int a = 0; a < P.size(); a ++) { for (int b = a + 1; b < P.size(); b ++) { for (int c = 0; c < P.size(); c ++) { if (a == c || b == c) continue; int p = P[a], q = P[b], r = P[c]; if (dst(p, r) + dst(q, r) >= A && abs(K[r] - K[q] >= B)) { dp[i][r][q] = dp[i][r][q] || dp[i ^ (1 << r)][q][p]; dp[i][r][p] = dp[i][r][p] || dp[i ^ (1 << r)][p][q]; if (dp[i][r][q] || dp[i][r][p]) { ans = max(ans, (int)P.size()); } } } } } } } cout << ans << endl; }