#include <iostream>
using namespace std;
int main()
{
int l, m, u, v;
int t[10050] = {};
cin >> l >> m;
int c = 0;
while (m--)
{
cin >> u >> v;
for (int i = u; i <= v; i++)
if (t[i] == 0)
{
t[i] = 1;
c++;
}
}
cout << l + 1 - c;
return 0;
}