N, A, B = map(int, input().split()) XYK = [tuple(map(int, input().split())) for i in range(N)] dp = {(1 << i, -1, i)for i in range(N)} # print(dp) for k in range(1, N): dp_ = set() for b, s, t in dp: for j in range(N): if (1 << j) & b > 0: continue if abs(XYK[t][2]-XYK[j][2]) >= B: dp_.add(((1 << j) | b, t, j)) continue if abs(XYK[j][0]-XYK[t][0])+abs(XYK[j][1]-XYK[t][1]) >= A: dp_.add(((1 << j) | b, t, j)) continue if s != -1 and abs(XYK[j][0]-XYK[t][0])+abs(XYK[j][1]-XYK[t][1])+abs(XYK[j][0]-XYK[s][0])+abs(XYK[j][1]-XYK[s][1]) >= A: dp_.add(((1 << j) | b, t, j)) dp = dp_ # print(dp) if dp: continue print(k) break else: print(N)