#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define speed                     \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define ll long long
#define ld long double
#define pb push_back
#define mem1(a) memset(a, -1, sizeof(a))
#define mem0(a) memset(a, 0, sizeof(a))
#define setp(x) fixed << setprecision(x)
#define endl "\n"
#define mod 1000000007
#define mod1 998244353
#define ff first
#define ss second
#define MAX 500005
#define N 500
#define INF 1000000009
#define all(v) v.begin(), v.end()
#define sbit(a) __builtin_popcount(a)
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef pair<ll, ll> pll;
typedef pair<pll, ll> ppl;
typedef map<ll, ll> mpll;
typedef map<vector<ll>, ll> mpvl;
ll power(ll x, ll y)
{
    ll res = 1;

    x = x;

    if (x == 0)
        return 0;
    while (y > 0)
    {

        if (y & 1)
            res = (res * x);

        y = y >> 1;
        x = (x * x);
    }

    return res;
}
void solve()
{
    ll n, m;
    cin >> n >> m;
    vector<ll> a;
    for (ll i = 0; i < m; i++)
    {
        ll x;
        cin >> x;
        a.pb(x);
    }
    a.pb(0);
    a.pb(n);
    sort(all(a));
    if (n == m)
    {
        cout << 0 << endl;
        return;
    }
    if (m == 0)
    {
        cout << 1 << endl;
        return;
    }
    vector<ll> v;
    ll len = a.size();
    for (ll i = 1; i < len - 1; i++)
    {
        v.pb(a[i] - a[i - 1] - 1);
    }
    v.pb(a[len - 1] - a[len - 2]);
    ll mn = 1e18;
    for (auto it : v)
    {
        if (it != 0)
        {
            mn = min(mn, it);
        }
    }
    ll ans = 0;
    for (auto it : v)
    {
        ans += (it / mn);
        if (it % mn)
            ans++;
    }
    cout << ans << endl;
}
int main()
{

    speed;
    ll kk;
    kk = 1;
    //cin >> kk;
    while (kk--)
    {
        solve();
    }
}
#include <bits/stdc++.h>
using namespace std;
int n, m, a[1005], b[1005], dp[1005][1005];
int main (){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
cin >> n >> m;
for (int i=1; i<=n; i++) cin >> a[i];
for (int i=1; i<=m; i++) cin >> b[i];
for (int i=1; i<=max(n, m); i++)
	dp[0][i]=dp[i][0]=i;
for (int i=1; i<=n; i++){
	for (int j=1; j<=m; j++){
		dp[i][j] = min({dp[i-1][j-1]+int(a[i]!=b[j]), dp[i-1][j]+1, dp[i][j-1]+1});
	}
} cout << dp[n][m];
return 0;
}