#include<cstdio>

int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    int tree[n];
    for(int i = 0 ; i < n ;++i){
        tree[i] = 1;
    }
    for(int idx = 0  ; idx < m ;++idx){
        int left ,right ;
        scanf("%d%d",&left,&right);
        for(int i = left -1 ;i < right ;++i){
            tree[i] = 0;
        }
    }
    int count =1;
    for(int i = 0 ; i < n ;++i){
        if(tree[i] == 1){
            ++count;
        }
    }
    printf("%d\n",count);
}