#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9 + 7;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> a(m+1, 0), b(m, 0);
    rep1(i, m) cin >> a[i];
    rep1(i, m-1){
        if (a[i+1] - a[i]<=1){
            cout << 0 << endl;
            return 0;
        }
        b[i] = a[i+1] - a[i] - 2;
    
    return 0;
    //printf("%.12f", ans);
}
