loop do
  n,k = gets.split.map(&:to_i)
  exit if n == 0 and k == 0
  a = k.times.map{gets.to_i}.sort
  bak = -3
  count = []
  chunk = []
  use_white = false
  a.each do |i|
    if i - bak == 1
      count[-1] += 1
      chunk[-1] += 1
    elsif i - bak == 2 and not use_white
      count[-1] += 2
      chunk << 1
      use_white = true
    elsif i - bak == 2 and use_white
      count << chunk.last + 2
      chunk << 1
      use_white = true
    elsif
      count << 1
      chunk << 1
      use_white = false
    end
    bak = i
  end
  result = (a.first == 0) ? count.max : chunk.max
  puts(result)
end