#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define INF (1<<29)
using namespace std;
typedef long long ll;
int main(){
      int n,k;
      while(cin>>n>>k&&n&&k){
            bool f[100001];
            int a,ans=-1;
            bool white=false;
            memset(f,false,sizeof(f));
            REP(i,k){
                  cin>>a;
                  if(a==0)white=true;
                  else f[--a]=true;
            }
            int cur=0,next;
            while(cur<n){
                  if(!f[cur]){
                        cur++;
                        continue;
                  }
                  next=cur;
                  while(f[next])next++;
                  ans=max(ans,next-cur);
                  if(white&&next<=n&&f[++next]){
                        while(f[next])next++;
                        ans=max(ans,next-cur);
                  }
                  cur++;
            }
            cout<<ans<<endl;
      }
}