#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int main() {
  while(1) {
    int n,k;
    cin >> n >> k;
    if (!n) break;
    vector<int> v(n+1);
    for (int i = 0; i < k; ++i) {
      int a;
      cin >> a;
      v[a] = 1;
    }
    int l=0;
    int zero = 0;
    int max_len = 0;
    for (int i = 1; i <= n; ++i) {
      if (v[i] == 0) {
        zero++;
      }
      while(zero > v[0]) {
        if(v[++l] == 0) {
          zero--;
        }
      }
      max_len = max(max_len, i - l);
    }
    cout << max_len << endl;
  }
  return 0;
}