#include<bits/stdc++.h> using namespace std; const int N=1e4+5; int l,m,u,v,s; bool t[N]; int main(){ cin>>l>>m; for(int i=1;i<=m;i++){ cin>>u>>v; for(int j=u;j<=v;j++) t[j]=1; } for(int i=1;i<=l;i++) if(t[i]==0) s++; cout<<s+1; return 0; }