#include<stdio.h>
int main()
{
int L,M;
int i,initial,end,l=0,nb=0;
scanf("%d%d",&L,&M);
int road[L+1];
for(i=0;i<=L;i++)
road[i]=0;
for(i=0;i<M;i++){
scanf("%d%d",&initial,&end);
for(l=initial;l<=end;l++)
road[l]=1;
}
for(i=0;i<L+1;i++){
if(road[i]==0)
nb++;
}
printf("%d",nb);
return 0;
}