#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
	int n, m;
	cin >> n >> m;

	vector<int> c(m), d(m);
	rep(i, m) cin >> c[i] >> d[i];

	int cnt[1005];
	memset(cnt, 0, sizeof(cnt));

	rep(i, m) {
		REP(j, c[i], d[i]) {
			cnt[j]++;
		}
	}

	int ans = 3 * (n + 1);
	rep(i, n + 1) {
		if(cnt[i] == 0) {
			ans -= 2;
		}
	}

	cout << ans << endl;

	return 0;
}