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

#define ll long long
#define all(x) x.begin(), x.end()

int main(){
	ios::sync_with_stdio(0); cin.tie(0);
	int n, m; cin >> n >> m;
	vector<array<int, 2>> black(m);
	for(auto &[x, y] : black) cin >> x >> y;
	set<int> white;
	white.insert(n);
	sort(all(black));
	for(int i = 0; i < m;){
		int cur = black[i][0];
		vector<int> rem, ins;
		while(i < m && cur == black[i][0]){
			int l = white.count(black[i][1] - 1), r = white.count(black[i][1] + 1);
			if(l + r == 0) rem.push_back(black[i][1]);
			else ins.push_back(black[i][1]);
			++i;
		}
		for(auto j : ins) white.insert(j);
		for(auto j : rem) white.erase(j); 
	}
	cout << (int)white.size() << "\n";
}

#include <cstdio>
#include <string>
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <bits/stdc++.h>
using namespace std;
/*----------------------------------ここからマクロ----------------------------------*/
#define f(i, n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define vb  vector<bool>
#define pii pair<int,int>
#define mii  map<int, int>
#define msi  map<string, int>
#define pii pair<int,int>
#define vpii  vector<pair<int, int>>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define len(x) ((int)(x).size())
#define contains(x,key) ((x).find(key) != (x).end())
#define cauto const auto
#define ll  long long
#define float long double
#define elif else if
#define exit return 0
const ll mod1 = 1000000007LL;
const ll mod2 = 998244353LL;
const int inf = 1 << 30;
const ll INF = 1LL << 60;
const float pi = 3.14159265358;
constexpr long long gcd(long long a, long long b) { while(b){ long long A = a; (a = b), (b = A % b); } return a; }
constexpr long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
constexpr int ctoi(const char c) { return ('0' <= c && c <= '9') ? (c - '0') : -1; }
constexpr const char* YesNo(bool b) { return b ? "Yes" : "No"; }
constexpr const char* YESNO(bool b) { return b ? "YES" : "NO"; }
constexpr const char* yesno(bool b) { return b ? "yes" : "no"; }
constexpr const char* yn(bool b) { return YesNo(b); }
template<class T> string join(const vector<T> &v){ stringstream s; rep (i, len(v)) s<<' '<<v[i]; return s.str().substr(1); }
template<class T> istream& operator>>(istream& is, vector<T>& v) { for (auto& x : v) is >> x; return is; }
template<class T> istream& operator>>(istream& is, vector<vector<T>>& v) { for(auto& x : v) for (auto& y : x) is >> y; return is; }
template<class T, class U> istream& operator>>(istream& is, pair<T, U>& p) { return is >> p.FI >> p.SE; }
template<class T> ostream& operator<<(ostream& os, const vector<vector<T>>& v){ rep (i, len(v)) { if (len(v[i])) os << join(v[i]) << (i-len(v)+1 ? "\n" : ""); } return os; }
void print(){ cout << "\n"; }
template<class T, class... A>void print(const T& v, const A&...args){cout << v; if(sizeof...(args))cout << " "; print(args...);}
void print_d(float i){ cout << fixed << setprecision(8) << i << endl; }


/*----------------------------------マクロここまで----------------------------------*/




int main() {
    fast;
    ll S, P;
    cin >> S >> P;

    for(ll i = 1; i*i <= P; i++){
        if(P%i != 0) continue;
        ll j = P / i;
        if(i+j == S){
            cout << "Yes" << endl;
            exit;
        }
    }

    cout << "No" << endl;
    return 0;
}