#include <bits/stdc++.h>
using namespace std;

bool b[100001];
pair<int, int> a[100000];

int main()
{
	int n, k;
	while (scanf("%d %d", &n, &k), n + k){
		memset(b, 0, sizeof(b));
		memset(a, 0, sizeof(a));
		
		int w = 0;
		for (int i = 0; i < k; i++){
			int a;
			scanf("%d", &a);
			if (a) b[a] = true;
			else w++;
		}
		
		int m = 0;
		int dif = 0;
		for (int i = 1; i <= n; i++){
			if (b[i]){
				a[m].first++;
				if (m > 0) a[m].second = max(a[m].second, dif);
				dif = 0;
			}
			else {
				dif++;
				if (m > 0 || a[m].first) m++;
			}
		}
		m++;
		
		//for (int i = 0; i < m; i++){
		//	printf("%d %d\n", a[i].first, a[i].second);
		//}
		
		int l = 0, r = 0, s = a[0].first, x = 0;
		int maxi = 0;
		while (r < m){
			//printf("%d %d %d %d\n", l, r, s, x);
			
			if (x > w){
				x -= a[l + 1].second;
				s -= a[l].first;
				l++;
			}
			else {
				maxi = max(maxi, s + w);
				
				r++;
				x += a[r].second;
				s += a[r].first;
			}
		}
		
		printf("%d\n", maxi);
	}
	
	return 0;
}