#!/usr/bin/ruby
# -*- coding: utf-8 -*-

loop do
  n, k = gets.split(/ /).map(&:to_i)
  n > 0 or break
  cards = k.times.map{gets.to_i}.sort
  j = -1
  if cards[0] == 0 then
    cards.shift
    j = 2
  end
  last = -1
  cnt1 = 0
  cnt2 = 0
  maxcnt = 0
  cards.each do|c|
    if last+1 == c then
      cnt1 += 1
      cnt2 += 1
    elsif last+j == c then
      cnt1 = cnt2+1
      cnt2 = 1
    else
      cnt1 = 1
      cnt2 = 1
    end
    if cnt1 > maxcnt then
      maxcnt = cnt1
    end
    last = c
  end
  puts maxcnt
end