#include #include using namespace std; using namespace atcoder; typedef modint998244353 mint; typedef long long ll; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--) template bool chmin(T &a, const T &b) { if (a <= b) return false; a = b; return true; } template bool chmax(T &a, const T &b) { if (a >= b) return false; a = b; return true; } bool hav[15]; ll x[15], y[15], k[15]; ll a, b; int n; vector tr; int tar = 0; ll dist(int i, int j){ return abs(x[i] - x[j]) + abs(y[i] - y[j]); } int mx(int i){ if (tar == n) return 0; if ((int)tr.size() == 1){ if (a > dist(i, tr[(int)tr.size() - 1]) && b > abs(k[i] - k[tr[(int)tr.size() - 1]])) return 0; }else if ((int)tr.size() >= 2){ if (a > dist(i, tr[(int)tr.size() - 1]) + dist(i, tr[(int)tr.size() - 2]) && b > abs(k[i] - k[tr[(int)tr.size() - 1]])) return 0; } hav[i] = true; tr.push_back(i); int ret = 1; rep(j,0,n){ if (!hav[j]){ chmax(ret, mx(j) + 1); } } hav[i] = false; tr.pop_back(); return ret; } int main(){ cin >> n >> a >> b; rep(i,0,n){ cin >> x[i] >> y[i] >> k[i]; } int ans = 0; rep(i,0,n) chmax(ans, mx(i)); cout << ans << "\n"; }