#include <iostream>
#include<cstring>
using namespace std;

const int L = 10010;
bool tree[L];
int main() {
    int l,m;
    while(cin>>l>>m){
        memset(tree,0,sizeof tree);
        while(m--){
            int left,right;
            cin>>left>>right;
            for(int i=left;i<=right;i++){
                tree[i]=true;
            }
        }
        int count=0;
        for(int i=0;i<=l;i++)
            if(tree[i]==false)count++;
        cout<<count<<endl;
    }
}
// 64 位输出请用 printf("%lld")