n,d=map(int,input().split())l = []count=0sum_=0for i in range(n): l.append(sorted([int(x) for x in input().split()]))for i in l: if i[2]-i[0]>=d: sum_+=sum(i)//3 count+=1print(count,sum_)