#include<bits/stdc++.h>
#define X first
#define Y second
#define eb emplace_back
#define pb push_back
#define print1d(x) for(auto i : x){ cout << i << " ";} cout << '\n'
#define print2d(x) for(auto u : x){ print1d(u);} cout << "------" << '\n'
#define CLR(x, y) memset(x, y, sizeof(x))
#define ALL(X) X.begin(), X.end()
#define io_o() ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define mp(x, y) make_pair(x, y)
#define mpp(w, x, y, z) make_pair(mp(w, x), mp(y, z))
#define For(i, n) for(int i = 0; i < n; i++)
#define For1(i, n, m) for(int i = n; i < m; i++)
#define For2(X) for(auto x : X)
#define maxn 200005
#define pi = acos(-1)
using namespace std;
typedef long long ll;
const ll mod = (1e9)+7;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
//priority_queue<ll> pq; priority_queue<pii,vector<pii>, greater<pii>> pq;
//sort(a, a+n, greater<int>());
pll b[maxn];

int main(){
    io_o(); //cute!
    ll n, m; cin >> n >> m;
    set<ll> pos;
    pos.insert(n);
    For(i, m) {
        cin >> b[i].X >> b[i].Y;
    }
    sort(b, b+m);
    vector<ll> add, era;
    for(int i = 0; i < m; i++) {
        // cout << i << '\n';
        ll x = b[i].X, y = b[i].Y;
        if(x == 0) continue;
        if(y-1 >= 0 && pos.count(y-1)) {
            add.push_back(y);
            // cout << "push " << y << '\n';
        }
        else if(y+1 <= 2*n && pos.count(y+1)) {
            add.push_back(y);
            // cout << "push " << y << '\n';
        }
        if(pos.count(y)) {
            era.push_back(y);
            // cout << "erase " << y << '\n';
        }
        if(i == m-1 || x != b[i+1].X) {
            for(auto ii: era) {
                if(pos.count(ii)) 
                    pos.erase(ii);
            }
            // cout << "pos\n";
            // for(auto a: pos) cout << a << ' '; cout << '\n';
            for(auto ii: add) pos.insert(ii);
            add.clear(); era.clear();
            // for(auto a: pos) cout << a << ' '; cout << '\n';
        }
    }
    cout << pos.size() << '\n';

    return 0;
}
#include <bits/stdc++.h>
using namespace std;
long long c[64][64];
int main() {
	cin.tie(nullptr)->sync_with_stdio(false);
	c[0][0] = 1;
	for (int i = 1; i < 64; i++) {
		c[i][0] = c[i][i] = 1;
		for (int j = 1; j < i; j++) {
			c[i][j] = c[i - 1][j - 1] + c[i - 1][j];
		}
	}
	int a, b;
	long long k;
	cin >> a >> b >> k; k--;
	string ans = "";
	int cnta = a;
	int cntb = b;
	for (int i = 0; i < a + b; i++) {
		if (!cnta) {
			ans += 'b';
			cntb--;
		} else if (!cntb) {
			ans += 'a';
			cnta--;
		} else {
			if (k < c[cnta + cntb - 1][cnta - 1]) {
				ans += 'a';
				cnta--;
			} else {
				k -= c[cnta + cntb - 1][cnta - 1];
				ans += 'b';
				cntb--;
			}
		}
	}
	cout << ans << "\n";
}