#include <stdio.h>
#include <vector>
using namespace std;
int main(){
    vector<int> tree;
    int l,m;
    int low,high;
    scanf("%d%d",&l,&m);
    for(int i=0;i<=l;++i){
        tree.push_back(1);
    }
    for(int j=0;j<m;++j){
        scanf("%d%d",&low,&high);
        for(int i=low;i<=high;++i){
            tree[i]=0;
        }
    }
    int count=0;
    for(int i=0;i<=l;++i){
        if(tree[i]==1){++count;}
    }
    printf("%d",count);
    return 0;
}