#include <stdio.h> #include<stdbool.h> int main() { int number, count; scanf("%d %d", &number, &count); bool Arr[number]; for (int i = 0; i <= number; i++) { Arr[i] = 1; } while (count--) { int left, right; scanf("%d %d\n", &left, &right); for (int j = left; j <= right; j++) { Arr[j] = 0; } } int sum = 0; for (int k = 0; k <= number; k++) { if (Arr[k] == 1) { sum++; } } printf("%d", sum); return 0; }