import numpy as np
a=np.array(a)
n,k = map(int,input().split())
a = []
for i in range(n):
    a.append(list(map(int,input().split())))

for i in range(n-1):
    b = list(map(lambda x,y: x-y, a, a))
    if abs(b) >= 3:
        count += 1
        print(count)