num = 0
total_num = 0
a, b = map(int, input().split())
for i in range(a):
d = list(map(int, input().split()))
m = max(d)
n = min(d)
total = m - n
if total >= b:
num += 1
s = (d[0] + d[1] + d[2]) / 3
total_num += s
s = int(s)
print(num, int(total_num))