#include <array>
#include <cstdint>
#include <cstring>
#include <iostream>
#include <numeric>

int main() {
    int L, M, b, e;
    std::cin >> L >> M;
    std::array<int8_t, 10001> bits;
    memset(bits.data(), 1, L + 1);
    while (M > 0) {
        std::cin >> b >> e;
        memset(bits.data() + b, 0, e - b + 1);
        --M;
    }
    int count = std::accumulate(bits.begin(), bits.begin() + L + 1, 0);
    std::cout << count << std::endl;
}