#include<iostream>

using namespace std;

int main() {
	
	int L, M;
	
	while (cin >> L >> M) {
		int s[100], e[100];
		int n = 0;

		for (int i = 0;i < M;i++) {
			int a, b;
			cin >> a >> b;
			
			if (a < 0) {
				a = 0;
			}
			if (b > L) {
				b = L;
			}
			if (a <= b) {
				s[n] = a;
				e[n] = b;
				++n;
			}
		}

		for (int i = 1;i < n;i++) {
			int ks = s[i], ke = e[i], j = i - 1;
			while (j >= 0 && s[j] > ks) {
				s[j + 1] = s[j];
				e[j + 1] = e[j];
				--j;
			}
			s[j + 1] = ks;
			e[j + 1] = ke;
		}

		int removed = 0;
		if (n > 0) {
			int curL = s[0], curR = e[0];
			for (int i = 1;i < n;i++) {
				if (s[i] <= curR + 1) {
					if (e[i] > curR) {
						curR = e[i];
					}
				}
				else {
					removed = removed + curR - curL + 1;
					curL = s[i];
					curR = e[i];
				}
			}
			removed = removed + curR - curL + 1;
		}

		cout << (L + 1 - removed) << endl;
	}
	return 0;
}