#include <bits/stdc++.h>
using namespace std;
bool a[10001];
int main()
{
int l, x, ans = 0;
cin >> l >> x;
for (int i = 0; i <= l; ++i)
a[i] = 1;
for (int t = 1; t <= x; ++t)
{
int n, m;
cin >> n >> m;
for (int i = n; i <= m; ++i)
a[i] = 0;
}
for (int i= 0; i <= l; ++i)
if (a[i]) ans++;
cout << ans << endl;
return 0;
}