#include using namespace std; const int N = 10010; int M, L; bool st[N]; int res; int main() { cin >> L >> M; while (M--) { int l, r; cin >> l >> r; for (int i = l; i <= r; i++) st[i] = true; } for (int i = 0; i <= L; i++) if (!st[i]) res++; cout << res << endl; return 0; }