import sys read=sys.stdin.buffer.read readline=sys.stdin.buffer.readline readlines=sys.stdin.buffer.readlines n, b=map(int, readline().split()) xyp=list(map(int, read().split())) xs=xyp[::3] ys=xyp[1::3] ps=xyp[2::3] ans=0 for xl in xs: for xr in xs: if xl>xr: continue z=[(y, p) for x, y, p in zip(xs, ys, ps) if xl<=x and x<=xr] z.sort() s=0 l=0 for r, q in enumerate(z): s+=q[1] if rb or (l>0 and z[l-1][0]==z[l][0])): s-=z[l][1] l+=1 if ans