#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
pair<int,int> b[1000001];
int main()
{
	int l,m,sum,sum1,i,s;
	cin>>l>>m;
	for(i=0;i<m;i++)
		cin>>b[i].first>>b[i].second;
	sort(b,b+m);
	s=b[0].second;
	sum=b[0].second-b[0].first+1;
	for(i=1;i<m;i++)
	{
		if(b[i].second<=s)
		    continue;
		else if(b[i].first<=s)
		{
			b[i].first=s+1;
			s=b[i].second;
		}
		sum+=b[i].second-b[i].first+1;
	}
	sum1=l-sum+1;
	cout<<sum1;
	return 0;
}