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

int main(){
    vector<pair<int, int>> cd;
    int N, m, c, d;
    cin >> N >> m;
    int ans = N + 1;
    for(int i = 0; i < m; ++i){
        cin >> c >> d;
        cd.push_back({c, d});
    }
    sort(cd.begin(), cd.end());
    int start = 0, end = 0;
    for(int i = 0; i < m; ++i){
        if(start == 0){
            start = cd[i].first;
        }
        if(cd[i].first <= end || end == 0){
            if(cd[i].second > end){
                end = cd[i].second;
            }
        }else{
            ans += 2 * (end - start);
            start = cd[i].first;
            end = cd[i].second;
        }
    }
    ans += 2 * (end - start);
    cout << ans << endl;
}
