#include <bits/stdc++.h>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define pmod 1000000007
#define maxn 100005
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(int i=a ; i<=b ; i++)
#define INF 1000000000
#define ll long long int
#define eps (1e-8)
#define sq(x) ( (x)*(x) )

using namespace std;

typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
priority_queue<pii,vector<pii>, greater<pii> > q;
ll res=0;
int a[1000],b[1000],c1[1051],d1[1051];
int main()
{int N,m;
cin>>N>>m;
FOR (i,1,m){int c,d;
    cin>> c>>d;
    q.push(mp(c,d));
    c1[i]=c;d1[i]=d;
    //if (c==3 && d==86) cout<<123<<endl;
}
int t=1;int k=0;
while (!q.empty()){
    int c1=q.top().first;
    int d1=q.top().second;
    q.pop();
    if (!q.empty()){int c2=q.top().first;
    int d2=q.top().second;
    //if (c1==3 && d1==86) cout<<"dm"<<" "<<c2<<" "<<d2<<endl;
    //if (k<=10) {k++;cout<<c1<<" "<<d1<<" "<<c2<<" "<<d2<<endl;}

        if (d1>=c2){

        q.pop();
        q.push(mp(c1,max(d1,d2)));


    }
    else {res+=2*(d1-c1);}
    }
    else {res+=2*(d1-c1);}
}
cout<<res+N+1<<endl;
/*FOR(i,1,m){ bool u=0;
    FOR(j,1,t-1){
        if (c1[i]>=a[j] && d1[i]<=b[j]) u=1;

    }
    if (u==0) cout<<i<<" "<<c1[i]<<" "<<d1[i]<<endl;
}*/
         return 0;
}