n, k = map(int, input().split())
a=[]
amax =0
acount =0
for i in range(n):
  a.append(int(input()))
  if i > 0:
    if abs(a[i]-a[i-1]) <= 3:
      #print(a[i])
      acount +=1
  else:
      #print(a[i])
      acount += 1
print(acount)