#include<iostream> using namespace std; int tree[10010]={0}; int main(){ int l,m,a,b,s=0; cin>>l>>m; for(int i=0;i<m;i++){ cin >> a >> b; for(int j=a;j<=b;j++) tree[j]=1; } for(int i=0;i<=1;i++) if(tree[i]==0) s++; cout<<s<<endl; return (0); }