#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<ctime>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<bitset>
#include<functional>
#include <fstream>
//#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i, x) for(ll i = 0; i < x; i++)
#define rep2(i, x) for(ll i = 1; i <= x; i++)
#define rep3(i, x, y) for(ll i = x; i < y; i++)
#define rep4(i, x) for(ll i = x; i >= 0; i--)
#define all(a) (a).begin(),(a).end()
#define puts(x) cout << (x) << "\n"
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const int intINF = 1000000000;
const ll mod = 1000000007;
const ll MOD = 998244353;
const ld pi = 3.141592653589793238;
//const ld EPS = 1e-9;

bool isprime(int p) {
	if (p == 1) return false;
	for (int i = 2; i < p; i++) {
		if (p % i == 0) return false;
	}
	return true;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
//ax + by = cが整数解をもつための必要十分条件は c が gcd(a,b) で割り切れること。
// 返り値: a と b の最大公約数
// ax + by = gcd(a, b) を満たす (x, y) が格納される
//main関数内に extGCD(a, b, x, y); でx, yに解が格納
ll extGCD(ll a, ll b, ll& x, ll& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	ll d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll keta(ll n) {
	ll res = 0;
	while (n >= 1) {
		res += n % 10; n /= 10;
	}
	return res;
}
ll modpow(ll x, ll y, ll m) {
	ll res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= m; }
		x = x * x % m; y /= 2;
	}
	return res;
}
ll kaijyo[600005];
void nCkinit(ll n, ll m) {
	ll cnt = 1; kaijyo[0] = 1;
	for (int h = 1; h <= n; h++) { cnt *= h; cnt %= m; kaijyo[h] = cnt; }
}
ll nCk(ll n, ll k, ll m) {
	/*ll a = 1, b = 1;
	for (int h = 1; h <= n; h++) { a *= h; a %= m; }
	for (int h = 1; h <= k; h++) { b *= h; b %= m; }
	for (int h = 1; h <= n - k; h++) { b *= h; b %= m; }*/
	ll a = kaijyo[n], b = kaijyo[k] * kaijyo[n - k] % m;
	return a * modpow(b, m - 2, m) % m;
}
//printf("%.10f\n", n);
typedef pair <ll, ll> P;
typedef pair <ll, string> pp;
ll dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
struct edge { ll to, cost; };
struct xy { ll x, y; };
struct status {
	ll cost;
	ll x;
	ll y;

	bool operator<(const status& rhs) const { return cost < rhs.cost; };
	bool operator>(const status& rhs) const { return cost > rhs.cost; };
};

map<ll, set<ll>> ma;
map<ll, bool> ok;
void dfs(ll x, ll y) {
	//まず自分の下にあるかどうか
	auto itr1 = ma[y].lower_bound(x + 1);
	ll sita = 0;
	if (itr1 == ma[y].end()) { ok[y] = true; sita = INF; }
	else { sita = *itr1; }
	//y-1
	if (y != 0) {
		ll now = x + 1;
		while (true) {
			auto itr2 = ma[y - 1].lower_bound(now);
			if (itr2 == ma[y - 1].end()) { break; }
			if (sita < *itr2) { break; }
			now = *itr2;
			ma[y - 1].erase(now); dfs(now, y - 1);
		}
	}
	//y + 1
	ll now = x + 1;
	while (true) {
		auto itr2 = ma[y + 1].lower_bound(now);
		if (itr2 == ma[y + 1].end()) { break; }
		if (sita < *itr2) { break; }
		now = *itr2;
		ma[y + 1].erase(now); dfs(now, y + 1);
	}
}

int main() {
	ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	//cout << fixed << setprecision(15);

	ll n, m; cin >> n >> m; vector<ll>x(m), y(m);
	rep(i, m) {
		cin >> x[i] >> y[i]; ma[y[i]].insert(x[i]);
	}
	/*for (int i = max((ll)0, n - m - 1); i <= n + m + 1; i++) {
		sort(all(ma[i]));
	}*/
	dfs(0, n);
	ll ans = 0;
	for (int i = max((ll)0, n - m - 1); i <= n + m + 1; i++) {
		if (ok[i]) { ans++; }
	}
	cout << ans << endl;
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2,fma,tune=native")

#define ll long long
#define int ll
#define ull unsigned ll
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
//#define inf 1010000000
#define inf 4000000000000000000
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define ykh mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#ifdef i_am_noob
#define bug(...) cerr << "#" << __LINE__ << ' ' << #__VA_ARGS__ << "- ", _do(__VA_ARGS__)
template<typename T> void _do(vector<T> x){for(auto i: x) cerr << i << ' ';cerr << "\n";}
template<typename T> void _do(set<T> x){for(auto i: x) cerr << i << ' ';cerr << "\n";}
template<typename T> void _do(unordered_set<T> x){for(auto i: x) cerr << i << ' ';cerr << "\n";}
template<typename T> void _do(T && x) {cerr << x << endl;}
template<typename T, typename ...S> void _do(T && x, S&&...y) {cerr << x << ", "; _do(y...);}
#else
#define bug(...) 826
#endif
template<typename T> void print(T && x) {cout << x << "\n";}
template<typename T, typename... S> void print(T && x, S&&... y) {cout << x << ' ';print(y...);}

const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod;
const int maxn=200005;

//i_am_noob
//#define wiwihorz  
template<int N>
struct hash_table1{
    int ground=0,siz=0;
    bool vis[N+5]={0};
    int size(){return siz;}
    void insert(int x){x-=ground;if(!vis[x]) siz++;vis[x]=1;}
    void erase(int x){x-=ground;if(vis[x]) siz--;vis[x]=0;}
    int count(int x){x-=ground;return vis[x];}
};

int n,m;
pii a[maxn];
map<int,vector<int>> mm;
hash_table1<maxn<<1> st;

void orzck(){
    cin >> n >> m;
    rep(m){
        int x,y;
        cin >> x >> y;
        if(y>=n-m&&y<=n+m) mm[x].pb(y);
    }
    st.ground=n-maxn;
    st.insert(n);
    for(auto p: mm){
        vector<int> vec=p.second;
        unordered_set<int> st1,st2;
        for(auto i: vec){
            if(st.count(i-1)||st.count(i+1)) st1.insert(i);
            else st2.insert(i);
        }
        for(auto i: st1) st.insert(i);
        for(auto i: st2) st.erase(i);
    }
    print(sz(st));
}

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    #ifdef i_am_noob
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    freopen("output2.txt","w",stderr);
    #endif
    cout << fixed << setprecision(15);
    int t;
    #ifdef wiwihorz
    cin >> t;
    #else
    t=1;
    #endif
    while(t--) orzck();
    return 0;
}