#include <iostream>
using namespace std;

int main() {
	int n, m, i, f[1002] = {0};
	cin >> n >> m;
	for (i = 0; i < m; i++) {
		int c, d;
		cin >> c >> d;
		f[c]++;
		f[d]--;
	}
	int ans = n + 1;
	for (i = 1; i < n + 2; i++) {
		f[i] += f[i - 1];
		if (f[i]) ans += 2;
	}
	cout << ans << endl;
	return 0;
}