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