#include <bits/stdc++.h>
using namespace std;
long long dp[5007], a[5007];
int main() {
  long long n, m, i, j, res;
  double x;
  cin >> n >> m;
  for (i = 0; i < n; i++) cin >> a[i] >> x;
  res = 1;
  dp[0] = 1;
  for (i = 1; i < n; i++) {
    dp[i] = 1;
    for (j = 0; j < i; j++) {
      if (a[i] >= a[j]) dp[i] = max(dp[i], dp[j] + 1);
    }
    res = max(res, dp[i]);
  }
  cout << n - res << endl;
  return 0;
}
