#include <bits/stdc++.h>
using namespace std;
vector<int> v, ans;
int main() {
  int n, m;
  cin >> n >> m;
  int t = n;
  int ind, s;
  double x;
  vector<int>::iterator it;
  while (n--) {
    cin >> s >> x;
    if (upper_bound(v.begin(), v.end(), s) - v.begin() == ans.size()) {
      v.push_back(s);
      ans.push_back(s);
    } else {
      ind = upper_bound(v.begin(), v.end(), s) - v.begin();
      v[ind] = s;
      ans[ind] = s;
    }
  }
  cout << t - ans.size() << endl;
  return 0;
}
