/**
    In the name of Allah, the Most Gracious, the Most Merciful.
**/

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

typedef long long ll;

const int N = 3e5 + 5;

pair < int, int > ara[1005];
vector < pair < int, int > > ve;
int n, m, c, d, ans;

int main() {
#ifdef _OFFLINE_
        freopen("in.txt", "r", stdin);
#endif /// _OFFLINE_

        cin >> n >> m;
        for(int i=0; i<m; i++) {
                cin >> ara[i].first >> ara[i].second;
        }

        sort(ara, ara+m);

//        for(int i=0; i<m; i++) {
//                cerr << ara[i].first << " " << ara[i].second << "\n";
//        }

        if( !m ) {
                cout << n + 1 << "\n";
                exit(0);
        }

        int l = 0, r = 0;

        for(int i=0; i<m; i++) {
                if( r >= ara[i].first ) {
                        r = max(r, ara[i].second);
                }
                else if( r < ara[i].first ) {
                        if( l && r ) {
                                ve.push_back({l, r});
                        }
                        l = ara[i].first;
                        r = ara[i].second;
                }
                if( i == m-1 ) {
                        if( l && r ) {
                                ve.push_back({l, r});
                        }
                }
        }

//        cerr << endl;
//
//        for(int i=0; i<ve.size(); i++) {
//                cerr << ve[i].first << " " << ve[i].second << "\n";
//        }

        int len = ve.size(), pre = 0;

        for(int i=0; i<len; i++) {
                ans += ve[i].first - pre;
                ans += (ve[i].second - ve[i].first) * 3;
                pre = ve[i].second;
        }
        ans += (n+1) - pre;

        cout << ans << "\n";

        return 0;
}

