#include<stdio.h>
int main(void)
{
int l,m,u,v,count,i,k;
scanf("%d %d",&l,&m);
char trees[**l+1**]={'0'};
for(i=0;i<=l;i++)
trees[i]='1';
for(k=0;k<m;k++)
{
scanf("%d %d",&u,&v);
for(i=u;i<=v;i++)
trees[i]='0';
}
for(i=0;i<=l;i++)
if(trees[i]=='1')
count++;
printf("%d",count);
return 0;
}