N,A,B=map(int,input().split()) XYK=[list(map(int,input().split())) for _ in range(N)] dist = [[0]*N for _ in range(N)] distK = [[0]*N for _ in range(N)] for i in range(N): x1,y1,k1 = XYK[i] for j in range(N): x2,y2,k2 = XYK[j] dist[i][j] = dist[j][i] = abs(x1-x2)+abs(y1-y2) distK[i][j] = distK[j][i] = abs(k2-k1) visit = [0]*N def dfs(route:list): ret = len(route) for i in range(N): if visit[i]:continue i0,i1 = route[-2:] flg=0 if distK[i1][i]>=B: flg=1 else: if A<=dist[i][i1]+dist[i][i0]: flg=1 if flg: route.append(i) visit[i]=1 ret2 = dfs(route) visit[i]=0 route.pop() ret = max(ret, ret2) if ret==N: print(N) exit() return ret def solve(): ret = 1 route = [] for i in range(N): route.append(i) visit[i]=1 for j in range(N): if i==j:continue if A<=dist[i][j] or B<=distK[i][j]: if ret==1:ret=2 route.append(j) visit[j]=1 ret2 = dfs(route) ret = max(ret, ret2) route.pop() visit[j]=0 visit[i]=0 route.pop() return ret print(solve())