#include <stdio.h>
int main() {
	int L, M;
	while (scanf("%d%d", &L, &M) != EOF) {
		int road[10001];
		for (int i = 0; i <= L; i++) {
			road[i] = 1;
		}
		for (int q = 0; q < M; q++) {
			int left, right;
			scanf("%d%d", &left, &right);
			for (int i = left; i <= right; i++) {
				road[i] = 0;
			}
		}
		int sum = 0;
		for (int j = 0; j <= L; j++) {
			if (road[j] == 1) {
				sum++;
			}
		}
		printf("%d", sum);
	}
	return 0;
}