#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int n, k, a, x[500000], dp[500000][2], chain, maxn;
bool hakushi, ok;
vector<int>p;

int main() {
	while (true) {
		hakushi = false;
		for (int i = 0; i < 500000; i++) { x[i] = 0; dp[i][0] = 0; dp[i][1] = 0; }
		cin >> n >> k;
		if (n == 0 && k == 0) { break; }
		for (int i = 0; i < k; i++) {
			cin >> a;
			if (a == 0) { hakushi = true; }
			else { x[a] = 1; }
		}
		if (hakushi == false) {
			chain = 0; maxn = 0;
			for (int i = 1; i <= n; i++) {
				if (x[i] == 1) {
					chain++;
				}
				else {
					maxn = max(maxn, chain);
					chain = 0;
				}
			}
		}

		else {
			maxn = 0;
			for (int i = 1; i <= n; i++) {
				if (x[i] == 1) {
					dp[i][0] = max(dp[i][0], dp[i - 1][0] + 1);
					dp[i][1] = max(dp[i][1], dp[i - 1][1] + 1);
				}
				else {
					dp[i][0] = 0;
					dp[i][1] = max(dp[i][1], dp[i - 1][0] + 1);
				}
			}
			for (int i = 1; i <= n; i++) { maxn = max(maxn, max(dp[i][0], dp[i][1])); }
		}

		cout << maxn << endl;
	}
	return 0;
}