#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;

ll n, k, a, d[100002];

int main() {
  while (1) {
    scanf("%lld%lld", &n, &k);
    if (n == 0) break;
    for (int i = 0; i <= n + 2; i++) d[i] = 0;
    bool flag = false;
    ll ans = 0;
    for (ll i = 0; i < k; i++) {
      scanf("%lld", &a);
      if (a == 0) { flag = true; continue; }
      d[a] = 1;
    }
    //for (ll i = 0; i < n + 2; i++) printf("%lld ",d[i]); printf("\n");
    ll counter = 0, temp = -1;
    for (ll i = 1; i <= n + 1; i++) {
      if (d[i] == 1) counter++;
      else if (d[i - 1] == 1) {
        ans = max(ans, counter + temp + 1);
        if (flag && d[i + 1] == 1) temp = counter;
        else temp = -1;
        counter = 0;
      } else temp = -1, counter = 0;
    }
    if (n == k) printf("%lld\n", n);
    else printf("%lld\n", ans);
  }
}

