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

int main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	constexpr int MAX_N = 1000;

	int n, m;
	cin >> n >> m;

	bitset<MAX_N> back;

	for(int i = 0; i < m; ++i) {
		int c, d;
		cin >> c >> d;

		if(c > d) continue;
		for(int j = c; j < d; ++j) {
			back[j] = true;
		}
	}

	cout << n + 1 + back.count() * 2 << endl;

	return EXIT_SUCCESS;
}