#include <iostream>
#include <vector>
#include <algorithm>

int main() {
    int n, m;
    std::cin >> n >> m;
    std::vector<int> a(m);
    for (int i=0; i<m; ++i) {
        std::cin >> a[i];
    }
    std::sort(a.begin(), a.end());
    std::vector<int> s;
    for (int i=0; i<=m; ++i) {
        int j;
        if (i == m) {
            j = n+1;
        } else {
            j = a[i];
        }
        int k;
        if (i == 0) {
            k = 0; 
        } else {
            k = a[i-1];
        }
        if (j-k-1 > 0) s.push_back(j-k-1);
    }
    if (s.size() == 0) {
        std::cout << 0 << std::endl;
        return 0;
    }
    int min = *std::min_element(s.begin(), s.end());
    int ans = 0;
    for (auto i : s) {
        ans += i/min;
        ans += i%min != 0 ? 1 : 0;
    }
    std::cout << ans << std::endl;
}

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

const int N = 810;
int n, k, a[N][N];
bool check(int mid)
{
	int s[N][N], d[N][N];
	memset(s, 0, sizeof(s));
	memset(d, 0, sizeof(d));
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= n; j++)	
		{
			s[i][j] = s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1] + (a[i][j] < mid); 
			d[i][j] = d[i - 1][j] + d[i][j - 1] - d[i - 1][j - 1] + (a[i][j] == mid); 
		}
	}
	for(int i = 1; i <= n - k + 1; i++)
	{
		for(int j = 1; j <= n - k + 1; j++)
		{
			int x = i + k - 1, y = j + k - 1;
			int t = s[x][y] - s[i - 1][y] - s[x][j - 1] + s[i - 1][j - 1];
			int cnt = d[x][y] - d[i - 1][y] - d[x][j - 1] + d[i - 1][j - 1];
			if(t + cnt >= k * k / 2 + k % 2) return true;
		}
	}
	return false;
}
int main()
{
	cin >> n >> k;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= n; j++)
		{
			cin >> a[i][j];
		}
	}
	int l = 0, r = 1e9;
	while(l < r)
	{
		int mid = l + r >> 1;
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	cout << l << endl;
	return 0;
} 




