#include <iostream>
using namespace std;

int main() {

  long long int n, m;
  cin >> n >> m;

  long long int v[1001] = {};

  for ( long long int i = 0; i < m; i++ ) {

    long long int in_c, in_d;
    cin >> in_c >> in_d;

    v[ in_c ]++;
    v[ in_d ]--;

  }

  for ( long long int i = 1; i <= n; i++ ) {
    v[i] += v[i-1];
  }

  long long int ans = 0;

  for ( long long int i = 0; i <= n; i++ ) {

    if ( v[i] == 0 ) {
      ans += 1;
    }else {
      ans += 3;
    }

  }

  cout << ans << endl;

  return 0;

}