#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppi;

#define INF 1000000000

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> shops(n,0);

  rep(i,m){
    int c,d;
    scanf("%d %d", &c,&d);
    shops[c-1]++;
    shops[d-1]--;
  }

  repl(i,1,n){
    shops[i] += shops[i-1];
  }

  int res=n+1;
  bool flg=false;
  int start;
  rep(i,n){
    if((!flg) && shops[i]>0){
      flg=true;
      start=i;
    }
    else if(flg && shops[i]==0){
      flg=false;
      res += (i-start)*2;
    }
  }

  cout << res << endl;
  
  return 0;
}