#define _CRT_SECURE_NO_WARNINGS
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
#include <bits/stdc++.h>
using namespace std;
int a[10050];
int main()
{
    int l, m;
    cin >> l >> m;
    a[0] = 1;
    for (int i = 0, x, y; i < m; i++)
        cin >> x >> y, a[x]--, a[y + 1]++;
    for (int i = 1; i <= l; i++)
        a[i] += a[i - 1];
    cout << count_if(a, a + l + 1, [](const auto x) { return x > 0; });
    return 0;
}
