#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m, i;
  cin >> n >> m;
  double temp;
  int a[n];
  for (i = 0; i < n; i++) {
    cin >> a[i] >> temp;
  }
  multiset<int> myset;
  for (i = 0; i < n; i++) {
    auto it = myset.upper_bound(a[i]);
    if (it == myset.end())
      myset.insert(a[i]);
    else {
      myset.erase(it);
      myset.insert(a[i]);
    }
  }
  cout << n - myset.size();
  return 0;
}
