#include <bits/stdc++.h>

using namespace std;

namespace {

    template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
        if (vs.empty()) return os << "[]";
        os << "[" << vs[0];
        for (int i = 1; i < vs.size(); i++) os << " " << vs[i];
        return os << "]";
    }

    int N, M;
    vector< pair<int, int> > P;
    void input() {
        cin >> N >> M;
        P.resize(M);
        for (int i = 0; i < M; i++) {
            cin >> P[i].first >> P[i].second;
        }
    }

    void solve() {
        if (M == 0) {
            cout << N + 1 << endl;
            return;
        }
        sort(P.begin(), P.end());
        int ans = N + 1;
        int l = P[0].first, r = P[0].second;
        int k = 1;
        while (true) {
            int a = P[k].first, b = P[k].second;
            if (l <= b && a <= r) {
                l = min(l, a);
                r = max(r, b);
                k++;
            } else {
                ans += 2 * (r - l);
                l = a; 
                r = b;
                k++;
            }
            if (k == M) {
                ans += 2 * (r - l);
                break;
            }
        }
        cout << ans << endl;
    }
}

int main() {
    input(); solve();
    return 0;
}