#include<bits/stdc++.h>
using namespace std;
int ar[100005];
int main(){
	int n,m;
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++){
		ar[i]=n;
	}
	for (int i=0;i<m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		ar[a]=min(ar[a],b-a);
	}
	int ans=0;
	int car=n;
	for (int i=1;i<=n;i++){
		if (car==0){
			ans++;
			car=n;
		}
		car=min(car,ar[i]);
		car--;
	}
	printf ("%d\n",ans);
}