#include<iostream> using namespace std; int z[1000000]; int main() { int l,m,a,b,c,d=0,e,f; cin>>l>>m; for(a=1;a<=m;a++) { cin>>b>>c; for(e=b;e<=c;e++) { z[e]++; } } for(f=1;f<=l+1;f++) { if(z[f]==0) { d++; } } cout<<d; return 0; }