a,b=map(int,input().split())A=0c=0for i in range(a): x,y,z=sorted(map(int,input().split())) if z-x>=b: c+=1 A+=(x+y+z)//3
print(c,A)