#include <iostream>
using namespace std;
int main(){
  int N, m, c, d;
  cin >> N >> m;
  int imos[N+1];
  fill(imos, imos+N+1, 0);
  for(int i = 0; i < m; ++i){
    cin >> c >> d;
    ++imos[c];
    --imos[d];
  }
  int t = 0, ans = N+1;
  for(int i = 0; i <= N; ++i){
    t += imos[i];
    if(t > 0) ans += 2;
  }
  cout << ans << endl;
  return 0;
}