n,k = map(int,input().split())
l = []
cnt = 1
ans = 1
for i in range(n):
  l.append(int(input()))
for i in range(n):
  a = l[i]
  cnt = 1
  for j in range(i+1,n-i):
    if abs(l[j] - a) <= 3:
      a = l[j]
      cnt += 1
  ans = max(ans,cnt)
print(ans)