import std.stdio;

void main() {
	int n, m;
	scanf("%d %d\n", &n, &m);
	auto ck = new int[n];
	foreach (i; 0..m) {
		int l, r;
		scanf("%d %d\n", &l, &r);
		for (size_t j = l-1; j < r; ++j) {
			++ck[j];
		}
	}
	size_t cnt;
	foreach(x; ck) {
		if (x == m) ++cnt;
	}
	cnt.write;
}
