#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <array>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <cstring>
#include <unordered_map>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int L;
    cin >> L;
    vector<vector<ll>> comb(L + 1, vector<ll>(L + 1));
    for(int i = 0; i <= L; ++i){
        comb[i][0] = comb[i][i] = 1;
    }
    for(int i = 1; i <= L; ++i){
        for(int j = 1; j < i; ++j){
            comb[i][j] = comb[i - 1][j] + comb[i - 1][j - 1];
        }
    }
    cout << comb[L - 1][11] << endl;

    return 0;
}
#include <bits/stdc++.h>

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;

const int MAXN = 1000100, MAXK = 30;
//const ll MOD = 998244353;
const ll INF = 1e13;
const ld PI = asin(1) * 2;
const ld EPS = 1e-6;

unordered_set<int> pos, tmp;
int n, m;
map<int, vi> black;

int main()
{
    FAST_IO;

    cin >> n >> m;
    pos.insert(n);
    REP(m) {
        int x, y;
        cin >> x >> y;
        black[x].pb(y);
    }

    for (auto p : black) {
        vi ins, del;
        for (int j : p.s) {
            bool ok = false;
            if (pos.count(j-1) || pos.count(j+1))
                ok = true;
            if (ok) {
                //pos.insert(j);
                ins.pb(j);
                //cout << "  inserting j=" << j << endl;
            } else {
                //pos.erase(j);
                del.pb(j);
                //cout << "  erasing j=" << j << endl;
            }
        }
        for (int x : ins) pos.insert(x);
        for (int x : del) pos.erase(x);

        /*cout << " after x = " << p.f << ",  pos: ";
        for (int x : pos) cout << x << " ";
        cout << endl;*/
    }

    cout << (int)pos.size() << "\n";

    return 0;
}

