hdh1103 @ 2024-03-15 23:09:25
#include <iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include <math.h>
#include <set>
#include <map>
#include <vector>
#include <set>
//#include <unordered_set>
#define ll long long
using namespace std;
ll a[10005] = {0};
int main()
{
ll l,m;
cin>>l>>m;
for(ll i=1;i<=m;i++){
ll x,y;
cin>>x>>y;
for(ll j = x;j<=y;j++){
a[j]=1;
}
}
ll sum = 0;
for(ll j = 0;j<=l;j++){
if(a[j]==0){
sum++;
}
}
cout<<sum;
return 0;
}