// E - White Pawn
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N, M; cin>>N>>M;
	int C = min(N, M), L = C*2 + 1;

	auto ixOk = [&](int y){ return 0 <= y && y < L; };

	vector<pair<int,int>> D;
	while(M--){
		int x, y; cin>>x>>y;
		y -= N - C;
		if(ixOk(y)) D.emplace_back(x, y);
	}
	sort(D.begin(), D.end());

	vector<int> Y, S(L); S[C] = 1;

	auto update = [&](){
		vector<int> A;
		for(int&y:Y)
			if((ixOk(y-1) && S[y-1]) || (ixOk(y+1) && S[y+1])) A.push_back(y);
		for(int&y:Y) S[y] = 0;
		for(int&y:A) S[y] = 1;
	};

	int px = 0;
	for(auto&[x, y]:D){
		if(px != x) update(), Y.clear(), px = x;
		Y.push_back(y);
	}
	update();
	cout<< accumulate(S.begin(), S.end(), 0) <<endl;
}

#include<bits/stdc++.h>
using namespace std;
using ll = long long;

#define F first
#define S second

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll n, m; cin >> n >> m;
    map<ll, vector<ll>> mp;
    for(int i = 0; i < m; i++){
    	ll x, y; cin >> x >> y;
    	mp[x].push_back(y);
    }
    set<ll> s;
    s.insert(n);
    for(auto &i: mp){
    	vector<ll> rem, ins;
    	for(auto &j: i.S){
    		ll l = s.count(j + 1);
    		ll r = s.count(j - 1);
    		if(l + r == 0) rem.push_back(j);
    		else ins.push_back(j);
    	}
    	for(auto &j: rem) s.erase(j);
    	for(auto &j: ins) s.insert(j);
    }
	cout << s.size() << '\n';
    return 0;
}
