#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define all(v) v.begin(),v.end()

vector<vector<ll>> memo;
vector<vector<ll>> g;
   ll N,M;
vector<ll> ind;
bool p;

bool dp(ll i,ll j) {

if(memo[i][j]>=0) {
    if(memo[i][j]==0) {
        return false;
    }
    else {
        return true;
    }
}

bool a=false;
ll now=g[i][j];

if(i<ind.size()-1&&ind[i+1]==ind[i]+1) {
    ll x=lower_bound(all(g[i+1]),now)-g[i+1].begin();
    x--;
    if(x>=0) {
    a|=dp(i+1,x);
    }

    if(x<0&&ind[i+1]==N) {
        a=true;
    }
}

if(ind[i]>0&&i>0&&ind[i-1]==ind[i]-1) {
    ll x=lower_bound(all(g[i-1]),now)-g[i-1].begin();
    x--;
    if(x>=0) {
        a|=dp(i-1,x);
    }
    if(x<0&&ind[i-1]==N) {
        a=true;
    }
}


if(ind[i]-1==N&&!p) {
    a=true;
}
if(ind[i]+1==N&&!p) {
    a=true;
}

if(a) {
    memo[i][j]=1;
}
else {
    memo[i][j]=0;
}

return a;



}





int main() {
 cin>>N>>M;
vector<pair<ll,ll>> vec(M);
for(ll i=0;i<M;i++) {
    ll X,Y;cin>>X>>Y;
    vec[i]=make_pair(Y,X);
}
sort(all(vec));

ind=vector<ll> (0);

for(ll i=0;i<M;i++) {
    ll x,y;
    tie(x,y)=vec[i];
    if(ind.size()==0||ind.back()!=x) {
        ind.push_back(x);
    }

}

g=vector<vector<ll>> (ind.size(),vector<ll> (0));
memo=vector<vector<ll>> (ind.size(),vector<ll> (0));

ll count=-1;
ll now=-1;
for(ll i=0;i<vec.size();i++) {
    if(vec[i].first!=now) {
        count++;
        now=vec[i].first;
    }
    g[count].push_back(vec[i].second);
    memo[count].push_back(-1);

}

    


ll ans=1;
p=false;
for(auto x:ind) {
    if(x==N) {
        p=true;
        continue;
    }
    ans++;
}







for(ll i=0;i<ind.size();i++) {
    if(!dp(i,g[i].size()-1)) {
        ans--;
    }
}



cout<<ans<<endl;
}




#include<iostream>
#include <string>
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#define ll long long int
#define ld long double
#define pb push_back
#define endl "\n"
#define mp make_pair
#define sz(v) (int)(v.size())
#define len(s) (ll)(s.length())
#define M 1000000007
#define all(v) v.begin(),v.end()
#define fr(a,b,c) for(ll i=a;i<=b;i+=c)
#define inarr(arr,n); for(ll i=0;i<n;i++) cin >> arr[i];
#define outarr(arr,n); for(ll i=0;i<n;i++) cout<<arr[i]<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll inf = 9e18;
const ld pi = 2*acos(0.0); 
using namespace std;
ll power(ll a,ll n) 
{
    if(n==0){
        return 1;
    }
    ll p=power(a,n/2) % M;
    p = (p * p) % M;
    if (n%2==1)
    {
        p=(p*a)%M;
    }
    return p;
}
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
}
const int N=1e6+5;
vector <ll> sieve(N,0); 
void si() 
{
    sieve[1]=1;
    for(int i=2;i<N;i++){
        if(sieve[i]==0){
            sieve[i]=1;
            for(int j=2*i;j<N;j+=i){
                sieve[j]=i;
            }
        }
    }
}
int main(){
    ios;
    ll n,m,t;
    cin>>n>>m>>t;
    ll prev=0;
    ll n1=n;
    for(int i=0;i<m;i++){
        ll l,r;
        cin>>l>>r;
        n-=(l-prev);
        if(n<=0){
            cout<<"No"<<endl;
            return 0;
        }
        n+=r-l;
        if(n>n1){
            n=n1;
        }
        prev=r;
    }
    n-=(t-prev);
    if(n<=0){
        cout<<"No"<<endl;
        return 0;
    }
    cout<<"Yes"<<endl;
    return 0;
}