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