#include <stdio.h> int main() { int l, m; int list1[10001]; scanf("%d %d", &l, &m); for (int j = 0 ; j <= l; j++) { list1[j] = 1; } for (int i = 0; i < m; i++) { int from, to; scanf("%d %d", &from, &to); for (int k = from; k <= to; k++) { list1[k] = 0; } } int treenum = 0; for (int i = 0; i <= l; i++) { if (list1[i] == 1) { treenum++; } } printf("%d", treenum); return 0 ; }