#include <bitset>
#include <cstdint>
#include <iostream>
#include <istream>
using namespace std;
using ll = int64_t;

const ll maxn=1e4+5;
ll l,m,ans;
bitset<maxn> vis;

int main(){
    iostream::sync_with_stdio(0),cin.tie(0),cout.tie(0);

    cin>>l>>m;
    for(ll i=1;i<=m;i++){
        ll a,b;
        cin>>a>>b;
        for(ll j=a;j<=b;j++){
            if(!vis[j]){
                vis[j]=true;
                ans++;
            }
        }
    }
    cout<<(l-ans+1)<<'\n';
}