#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }


int main(){
    ll n,m; cin>>n>>m;
    vector<ll> istwice(n+2, 0);
    rep(i,m){
        ll c,d; cin>>c>>d;
        istwice[c]++;
        istwice[d]--;
    }
    rep(i, n+1) istwice[i+1]+=istwice[i];
    ll res=n+1;
    rep(i, n+2){
        if(istwice[i]>0) res+=2;
    }
    cout<<res<<endl;
    return 0;
}
