#include <iostream> using namespace std; int main() { int L,M,sum; int minNum,maxNum; int tree[10001]; for(int i=0;i<10001;i++){ tree[i]=1; } scanf("%d %d",&L,&M); sum=L+1; while(M>0){ scanf("%d %d",&minNum,&maxNum); for(int j=minNum;j<maxNum+1;j++){ if(tree[j]==1){ sum--; tree[j]=0; } } M--; } printf("%d",sum); }