/***********************************
.-'''''-.
.' `.
: :
: :
: _/| :
: =/_/ :
`._/ | .'
( / ,|...-'
\_/^\/||__
_/~ `""~`"` \_
__/ -'/ `-._ `\_\__
/ /-'` `\ \ \-.\
*************************************/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef int ii ;
typedef char cc ;
typedef double dd ;
typedef bool bb ;
ii arr[10000][10000];
bb pd(int i){
if(i < 1) return false;
else return true;//对于是否有障碍的判断
}
int main() {
//step 1. 读题、声明变量
ii xx,yy;//实时侦测
ii bc,za;//边长与障碍数
ii x,y;//障碍所在的坐标(x,y)
//step 2. 输入
cin >> bc >> za;
//step 3. 处理
for(int i = 0;i < za;i++){
cin >> x >> y;
arr[x][y] = -999;
}//障碍
for(int i = 0;i < bc;i++){
for(int j = 0;j <bc;j++){
if(pd(arr[i][j]) == false) arr[i][j] = 1;
}
}//初始化
for(int i = 1;i < bc;i++){
for(int j = 1;j < bc;j++){
xx = arr[i - 1][j];
yy = arr[i][j - 1];
if(pd(xx) == true && pd(yy) == true) arr[i][j] = xx + yy;
}//处理
}
//step 4. 输出
// for(int i = 0;i < bc;i++){
// for(int j = 0;j < bc;j++){
// cout <<arr[i][j] << ' ';
// }
// cout << endl;
// }
cout << arr[bc - 1][bc - 1];
return 0;
}