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)] edge = [[] for _ in range(N*16)] 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) for i in range(N): for j in range(N): if i==j:continue if distK[i][j]>=B: for k1 in range(N): if k1==i or k1==j:continue v1 = i+(k1<<4) for k2 in range(N): if k1==k2:continue if k2==i or k2==j:continue v2 = j + (k2<<4) edge[v1].append(v2) edge[v2].append(v1) vij = i+(j<<4) for k in range(N): if dist[i][k]+dist[j][k]>=A: vki = k+(i<<4) edge[vij].append(vki) edge[vki].append(vij) visit = [0]*N def dfs(route:list): ret = len(route) i0,i1=route[-2:] for to in edge[route[-1]]: vto = to&0xF if visit[vto]:continue visit[vto]=1 route.append(to) ret2 = dfs(route) visit[vto]=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+(i<<4)) visit[j]=1 ret2 = dfs(route) ret = max(ret, ret2) route.pop() visit[j]=0 visit[i]=0 route.pop() return ret print(solve())