#include <bits/stdc++.h>
using namespace std;

int main(void){
    bool a[1001]={};
    int N,m,cnt=0;
    cin>>N>>m;
    while(m--){
        int c,d;
        cin>>c>>d;//d???c?????????????????????
        for(int i=c;i<d;++i)a[i]=true;//d??????c??????????????????
    }
    for(int i=0;i<=N;++i)if(a[i])cnt++;//?????£?????????????????°??????
    cout<<N+1+cnt*2<<endl;//N+1?????\?????£???????????£?????§????????¢???count*2???????????????

    return 0;
}