#include<bits/stdc++.h>
#define pb emplace_back
#define xx first
#define yy second
using namespace std;
typedef pair<int, int>pi;
vector<pi>vec;
bool vis[1003];
int main()
{
    int n, m, x, y;
    while(scanf("%d %d", &n, &m)==2)
    {
        vec.clear();
        for(int i=0; i<m; i++)
        {
            scanf("%d %d", &x, &y);
            vec.pb(x, y);
        }sort(vec.begin(), vec.end());
        memset(vis, 0, sizeof vis);
        int ans= 0, c= 0, temp= 0;
        for(int i=0; i<m; i++)
            if(!vis[i])
            {
                int l= vec[i].xx;
                int r= vec[i].yy;
                while(i<m)
                {
                    if(vec[i].xx>r)break;
                    r= max(r, vec[i].yy);
                    vis[i]= 1;
                    i++;
                }i--;
                ans+= (r-l); temp+= (r-l+1);c++;
            }
        ans= ((n-temp)+c+1) +(ans*3);
        printf("%d\n", ans);
    }

    return 0;
}

