#include <bits/stdc++.h>
using namespace std;
const int maxN = 5005;
const int INF = (int)1e9;
const int MOD = 7 + (int)1e9;
const double eps = 1e-9;
int dp[maxN];
int main(void) {
  int n, m;
  cin >> n >> m;
  vector<int> a(n + 1);
  for (int i = 0; i < n; i++) {
    double trash;
    cin >> a[i] >> trash;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int res = 0;
    for (int ii = a[i]; ii >= 0; ii = (ii & (ii + 1)) - 1) {
      res = max(dp[ii], res);
    }
    ans = max(ans, res + 1);
    for (int ii = a[i]; ii < maxN; ii = ii | (ii + 1)) {
      dp[ii] = max(dp[ii], res + 1);
    }
  }
  cout << n - ans << endl;
  return 0;
}
