#include<bits/stdc++.h> using namespace std; using ll=long long; using pii=pair<int,int>; #define all(a) a.begin(),a.end() #define pb push_back #define sz(a) ((int)a.size()) const int N=14; int n,x[N],y[N],k[N],A,B; bool dp[1<<N][N][N]; int dis(int i, int j){return abs(x[i]-x[j])+abs(y[i]-y[j]);} signed main(){ ios_base::sync_with_stdio(0),cin.tie(0); cin >> n >> A >> B; for(int i=0; i<n; ++i) cin >> x[i] >> y[i] >> k[i]; for(int i=0; i<n; ++i) dp[1<<i][i][i]=1; for(int i=0; i<n; ++i) for(int j=0; j<n; ++j) if(i!=j&&(dis(i,j)>=A||abs(k[i]-k[j])>=B)) dp[(1<<i)+(1<<j)][i][j]=1; for(int s=0; s<(1<<n); ++s) if(__builtin_popcount(s)>=2){ for(int i=0; i<n; ++i) for(int j=0; j<n; ++j) if(dp[s][i][j]){ for(int t=0; t<n; ++t) if(!(s>>t&1)){ if(abs(k[t]-k[j])>=B||dis(t,i)+dis(t,j)>=A) dp[s^(1<<t)][j][t]=1; } } } int res=1; for(int s=0; s<(1<<n); ++s) for(int i=0; i<n; ++i) for(int j=0; j<n; ++j) if(dp[s][i][j]) res=max(res,__builtin_popcount(s)); cout << res << "\n"; }