#include<bits/stdc++.h>
using namespace std;
int main()
{
int l,m,u[101],v[101];
cin>>l>>m;
int s=l+1,t[10001];
for(int i=0;i<m;i++)
cin>>u[i]>>v[i];
for(int j=0;j<m;j++)
{
for(int k=0;k<=l;k++)
{
if(k>=u[j]&&k<=v[j]) t[k]=1;
}
}
for(int h=0;h<=l;h++)
{
if(t[h]==1) s--;
}
cout<<s;
return 0;
}