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

int main(){
    int n, m; cin >> n >> m;
    vector<int> imos(n + 2, 0);
    for(int i = 0; i < m; i++){
        int c, d; cin >> c >> d;
        if(c < d){
            imos[c]++;
            imos[d]--;
        }
    }

    for(int i = 1; i <= n + 1; i++){
        imos[i] += imos[i - 1];
    }

    int counter = 0;
    for(int i = 0; i <= n + 1; i++){
        if(imos[i] > 0) counter++;
    }

    cout << n + 1 + counter * 2 << endl;
    return 0;
}
