#include <iostream> #include <cstring> using namespace std; int main() { int l,m; cin>>l>>m; bool road[l+1]; memset(road,true,sizeof(road)); while(m>0){ m--; int left,right; cin>>left>>right; for(int i=left;i<=right;i++){ road[i]=false; } } int num=0; for(int i=0;i<=l;i++){ if(road[i]) num++; } cout<<num<<endl; }