#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;

int main() {
  int N, M; cin >> N >> M;
  vector<pair<int,int>> V(M);
  for(int i = 0; i < M; ++i) {
    cin >> V[i].first >> V[i].second;
  }
  sort(V.begin(), V.end());
  int ans = N - 1 + 2;
  int index = 0;
  while(index < M) {
    // cerr << V[index].first << " -> ";
    int l = V[index].first;
    int r = V[index].second;
    while(index + 1 < M && V[index + 1].first <= r) {
      index++;
      r = max(r, V[index].second);
    }
    ans += (r - l) * 2;
    // cerr << r << endl;
    index++;
  }
  cout << ans << endl;
}