#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<int> vec;
  for (int i = 0; i < n; i++) {
    int x;
    double y;
    cin >> x >> y;
    vec.push_back(x);
  }
  vector<int> dp;
  for (int i = 0; i < n; i++) {
    if (dp.empty())
      dp.push_back(vec[i]);
    else {
      if (dp[0] > vec[i]) {
        dp[0] = vec[i];
        continue;
      }
      if (dp[dp.size() - 1] <= vec[i]) {
        dp.push_back(vec[i]);
        continue;
      }
      int go = upper_bound(dp.begin(), dp.end(), vec[i]) - dp.begin();
      dp[go] = vec[i];
    }
  }
  cout << n - dp.size();
  return 0;
}
