#include<bits/stdc++.h> using namespace std; int main() { int f[1001]={0}; int l,n,a,b,s=0; cin>>l>>n; for(int i=1;i<=n;i++) { cin>>a>>b; for(int j=a;j<=b;j++) { f[j]=1; } } for(int i=0;i<=l;i++) { if(f[i]==0) s++; } cout<<s; return 0; }