#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,x,y) for(int i=(x);i<y;i++)

struct S {
	int c, d;
};

int main()
{
	int N, m;

	cin >> N >> m;

	vector<S> data(m);

	rep(i, 0, m) {
		cin >> data[i].c >> data[i].d;
	}

	while (true) {
		bool flag = false;

		rep(i, 0, m) {
			if (data[i].c == 0 && data[i].d == 0) {
				continue;
			}

			rep(j, i + 1, m) {
				if (data[j].c == 0 && data[j].d == 0) {
					continue;
				}

				if (data[i].d > data[j].c&&data[i].c < data[j].d) {
					data[i].c = min(data[i].c, data[j].c);
					data[i].d = max(data[i].d, data[j].d);
					data[j].c = 0;
					data[j].d = 0;
					flag = true;
				}
			}
		}

		if (flag == false) {
			break;
		}
	}

	int ans = N + 1;

	rep(i, 0, m) {
		ans += (data[i].d - data[i].c) * 2;
	}

	cout << ans << endl;

	return 0;
}