ImposterAnYu @ 2021-12-17 22:41:53
#include<bits/stdc++.h>
#define int1 long long
using namespace std;
int1 n,m,a[1005],b[1005],i,j,s;
bool c[1005];
int main(){
cin >> n >> m;
for(i = 1; i <= m; i++){
cin >> a[i] >> b[i];
}
for(i = 1; i <= m; i++){
for(j = i + 1; j <= m; j++){
if(a[i] >= a[j] && b[i] <= b[j] && i != j){
c[i] = 1;
}
}
}
for(i = 1; i <= m; i++){
s += (!c[i]);
/*if(!c[i]){
cout<< i << endl;
}*/
}
cout<< s << endl;
return 0;
}