You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
431 B

#include <bits/stdc++.h>
using namespace std;
const int N = 10010;
int b[N];
int l;
int m;
int cnt;
int main() {
scanf("%d %d", &l, &m);
for (int i = 0; i <= l; i++) b[i] = 1;
while (m--) {
int u, v;
scanf("%d %d", &u, &v);
for (int i = u; i <= v; i++) b[i]--;
}
for (int i = 0; i <= l; i++)
if (b[i] == 1) cnt++;
printf("%d", cnt);
return 0;
}