N,A,B=map(int, input().split()) C=[] for i in range(N): x,y,k=map(int, input().split()) C.append((x,y,k)) from collections import deque d=deque() ans=1 for i in range(N): for j in range(N): if i==j: continue x,y,k=C[j];xx,yy,kk=C[i] bit=2**j+2**i f=0 if A<=abs(x-xx)+abs(y-yy): f=1 if B<=abs(k-kk): f=1 if f==1: ans=max(ans,2) d.append((bit,j,i)) for i in range(3,N+1): nd=deque() while d: bit,p,q=d.popleft() for j in range(N): if not (bit & (1<