loop do
    n, k = gets.split.map(&:to_i)
    break if n == 0 && k == 0
    cs = k.times.map{gets.to_i}.sort
    if cs[0] == 0
        max = Array.new
        i = 1
        while i < cs.size - 1
            s = cs[i]
            while cs[i] + 1 == cs[i+1]
                i += 1
            end
            t = cs[i]
            max.push([s, t])
            i += 1
            s = i
        end
        max1 = max.map{|s,t| t - s + 1}.max
        max2 = 0
        max.each_with_index do |st,i|
            next if i == 0
            if st[0] == max[i-1][1] + 2
                max2 = st[1] - max[i-1][0] + 1 if st[1] - max[i-1][0] + 1 > max2
            end
        end
        p [max1,max2].max
    else
        max = 0
        i = 1
        while i < cs.size - 1
            count = 1
            while cs[i] + 1 == cs[i+1]
                count += 1
                i += 1
            end
            max = count if count > max
            i += 1
        end
        p max
    end
end