/*
 * author: vongkh
 * created: Sun Jan 17 2021
 */

#include <stdio.h>
#include <cstdlib>
#include <map>

int64_t x, y;
std::map<int64_t, int64_t> memo;

int64_t get_operation_num(int64_t z){
    //get the number of operation need to transform z back to x
    //each stop we have three choices : increment, decrement, divide by 2
    //Observation: divide by 2 and +/- later is more efficient 
    if(memo.find(z) != memo.end()) return memo[z]; 
    if(z == 1) return std::abs(z - x);
    int64_t ans = std::abs(z - x);
    if(z%2){
        //if z is odd we can only do +/-
        ans = std::min(ans, get_operation_num(z-1)+1);
        ans = std::min(ans, get_operation_num(z+1) + 1);
    }else{
        //if z is even, it is optimal to try to /2
        ans = std::min(ans, get_operation_num(z/2) + 1);
    }
    return memo[z] = ans;
}

int main(){
    scanf("%lld %lld", &x, &y);
    //we solve this problem by thinking inversely
    //how to get x from y
    int64_t ans = get_operation_num(y);
    printf("%lld \n", ans);
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll n, m; cin >> n >> m;
    ll a[m + 2]; rep(i, 1, m)cin >> a[i];
    sort(a + 1, a + m + 1);
    a[0] = 0;
    a[m + 1] = n + 1;

    ll mn = INF;
    rep(i, 0, m){
        if(a[i + 1] - a[i] - 1 > 0){
            mn = min(mn, a[i + 1] - a[i] - 1);
        }
    }

    ll ans = 0;
    rep(i, 0, m){
        //print(mn)
        //print(a[i + 1] - a[i] - 1)
        ans += (a[i + 1] - a[i] - 1 + mn - 1) / mn;
    }
    print(ans)
    
    return 0;
}