#include<cstdio>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
typedef pair<int,int>P;//<beginNum,endNum>
int f(P p){return p.second-p.first+1;}
int main()
{
	int a[100000],n,k,i,b,l,x;
	while(scanf("%d%d",&n,&k),n)
	{
		for(i=0;i<k;++i)scanf("%d",&a[i]);
		vector<P>v;
		sort(a,a+k);
		for(i=!a[0],b=l=a[i];i+1<k;++i)
		{
			if(a[i]+1==a[i+1])++l;
			else v.push_back(P(b,l)),b=l=a[i+1];
		}
		v.push_back(P(b,l));
		if(!a[0])
		{
			P p,q,r,s;
			for(i=0;i+1<v.size();++i)
			{
				r=v[i],s=v[i+1];
				if(r.second+2==s.first && f(p)+f(q)<f(r)+f(s))p=r,q=s;
			}
			v.push_back(P(p.first,q.second));
		}
		for(x=i=0;i<v.size();++i)x=max(x,f(v[i]));
		printf("%d\n",x);
	}
	return 0;
}