#include using namespace std; typedef long long ll; const int INF = 1000000000; const ll INFL = 2e18; template bool chmin(T &a, T b){ if (a > b) { a = b; return true;} else return false;} template bool chmax(T &a, T b){ if (a < b) { a = b; return true;} else return false;} int main() { int N,M; cin >> N >> M; vector> RL; for (int i = 0;i < M;i++) { int L,R; cin >> L >> R; RL.push_back({R,L}); } sort(RL.begin(), RL.end()); int cnt = 0; for (int i = 0;i < M;i++) { int j = i; while (j < M && RL[i].first >= RL[j].second) { j++; } cnt++; i = j-1; } cout << N - cnt << endl; }