#include <bits/stdc++.h>
using namespace std;
using namespace std;
const long double PI = acos(-1.0);
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  ;
  int N, M, i, x;
  double y;
  cin >> N >> M;
  multiset<int> tmp;
  for (i = 0; i < N; ++i) {
    cin >> x >> y;
    tmp.insert(x);
    auto it = tmp.upper_bound(x);
    if (it != tmp.end()) tmp.erase(it);
  }
  cout << N - tmp.size();
  return 0;
}
