/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2021.05.31 03:48:48
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int n,m;cin >> n >> m;
    vector<bool> dp(min(n,m)*2+1);
    vector<pair<int,int>> a(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i].first >> a[i].second;
        a[i].second-=max(n-m,0);
    }
    dp[dp.size()/2] = 1;
    sort(a.begin(), a.end());
    for (int i = 0; i < m; i++) {
        int h = a[i].first;
        vector<int> v1,v2;
        while(i < m && h == a[i].first) {
            if (a[i].second < 0 || a[i].second >= dp.size()) {i++; continue;}
            v1.push_back(a[i].second);
            if ((a[i].second>=1 && dp[a[i].second-1]) || (a[i].second+1<dp.size() && dp[a[i].second+1])) {
                v2.push_back(a[i].second);
            }
            i++;
        }
        i--;
        for(int v:v1) dp[v]=false;
        for(int v:v2) dp[v]=true;
    }
    cout << accumulate(dp.begin(), dp.end(), 0) << endl;
    return 0;
}
#include <bits/stdc++.h>
 
using namespace std; 

#define int long long 

template <typename T> 
void print_vec(const vector<T>& v, bool newline = true) {
    for (int i = 0; i < v.size(); ++i) {
        cout << v[i] << " ";
    }
    if (newline) {
        cout << "\n";
    }
}
 
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 
 
const int maxn = (int)2e5 + 105;
const int mod = (int)998244353; 
 
#define sz(x) ((int)(x.size()))
 
#define pb push_back
#define rep(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
 
int fact_setup=0; int * fact; 
 
int ex (int a, int b){
    if(b==0)return 1; int e = ex(a,b/2); e=(1ll*e*e)%mod; if(b&1)e=(1ll*e*a)%mod; return e;
}
int inv (int a){
    return ex(a, mod - 2); 
}
int choose (int a, int b){
    if(!fact_setup){
        fact_setup=1; 
        fact = new int [maxn]; 
        fact[0]=1; rep (i,1,maxn-1) fact[i]=(i*fact[i-1])%mod; 
    }
    if(a<b)return 0; 
    int num = fact[a]; 
    int denom = (fact[b] * fact[a - b]) % mod; 
    return (num * inv(denom)) % mod; 
}
 
#define pii pair <int, int> 
#define pvi pair <vector <int>, int> 
 
#define pai array <int,2>
#define pdi array <double, 2> 
#define pdt array <double, 3>
 
#define pti array <int,3>
#define pfi array <int,4>
 
#define all(v) v.begin(), v.end()


main(){
    cin.tie(0); ios_base::sync_with_stdio(0); 
    int n, m; cin >> n >> m; 
    map<int,vector<int> >coord;  
    rep (i,1,m){
        int a,b;cin>>a>>b;
        coord[a].pb(b); 
    }
    map<int,int>vis;vis[n]=1; 
    for (auto i = coord.begin(); i!=coord.end(); i++){
        vector<int> v = i->second; 
        vector<pai>on; 
        for (int j : v){
            if(vis[j-1]||vis[j+1]) on.pb({j,1}); 
            else if(vis[j])on.pb({j,0}); 
        }
        for (auto j : on) vis[j[0]]=j[1]; 

    }
    int ans=0; 
    for (auto i = vis.begin();i!=vis.end(); i++){
        if (i->second)ans++; 
    }
    cout<<ans; 
    return 0; 
}