#37242: 簡易python


cyberdeng95@gmail.com (dvorakonetrick)


amount, dif = map(int, input().split())
spent = 0
bought = 0
for i in range(amount):
    a = [int(b) for b in input().split()]
    if (max(a) - min(a)) >= dif:
        spent += sum(a)/3
        bought += 1
print(bought, int(spent))