#include <algorithm>
#include <cstdio>
int dp[100000], dp2[100000], v[100000];
int main()
{
	int n, k;
	while (scanf("%d%d", &n, &k), n|k) {
		int w = 0;
		for (int i=0; i<k; ++i) {
			int t;
			scanf("%d", &t);
			if (t == 0)
				w = 1;
			else
				v[i-w] = t;
		}
		std::sort(v, v+k-w);
		dp[0] = 1;
		for (int i=1; i<k-w; ++i)
			dp[i] = v[i]-v[i-1]==1 ? dp[i-1]+1 : 1;
		bool used = false;
		if (w) {
			dp2[0] = 1, dp2[k-w] = 1000011;
			for (int i=1; i<k-w; ++i) {
				if (v[i] - v[i-1] == 1) {
					dp2[i] = dp2[i-1]+1;
				}
				else {
					if (v[i] - v[i-1] == 2) {
						dp2[i] = dp[i-1] + 2;
						used = true;
					}
					else {
						dp2[i] = 1;
					}
				}
			}
		}
		printf("%d\n", std::max(*std::max_element(dp, dp+k-w), *std::max_element(dp2, dp2+k-w)+!used));
	}
	return 0;
}